from header_common import *
from header_operations import *
from header_mission_templates import *
from header_animations import *
from header_sounds import *
from header_music import *
from header_items import *
from module_constants import *

from header_skills import *
from header_terrain_types import *
from module_my_mod_set import *

####################################################################################################################
#   Each mission-template is a tuple that contains the following fields:
#  1) Mission-template id (string): used for referencing mission-templates in other files.
#     The prefix mt_ is automatically added before each mission-template id
#
#  2) Mission-template flags (int): See header_mission-templates.py for a list of available flags
#  3) Mission-type(int): Which mission types this mission template matches.
#     For mission-types to be used with the default party-meeting system,
#     this should be 'charge' or 'charge_with_ally' otherwise must be -1.
#     
#  4) Mission description text (string).
#  5) List of spawn records (list): Each spawn record is a tuple that contains the following fields:
#    5.1) entry-no: Troops spawned from this spawn record will use this entry
#    5.2) spawn flags.
#    5.3) alter flags. which equipment will be overriden
#    5.4) ai flags.
#    5.5) Number of troops to spawn.
#    5.6) list of equipment to add to troops spawned from here (maximum 8).
#  6) List of triggers (list).
#     See module_triggers.py for infomation about triggers.
#
#  Please note that mission templates is work in progress and can be changed in the future versions.
# 
####################################################################################################################

pilgrim_disguise = [itm_pilgrim_hood,itm_pilgrim_disguise,itm_practice_staff, itm_throwing_daggers]
af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian

mission_templates = [

(
"town_default", 0, -1, 
"Default_town_visit",
[(0, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(1, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(5, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_scene_source, af_override_horse, 0, 1, []),
(9, mtef_scene_source, af_override_horse, 0, 1, []),
(10, mtef_scene_source, af_override_horse, 0, 1, []),
(11, mtef_scene_source, af_override_horse, 0, 1, []),
(12, mtef_scene_source, af_override_horse, 0, 1, []),
(13, mtef_scene_source, 0, 0, 1, []),
(14, mtef_scene_source, 0, 0, 1, []),
(15, mtef_scene_source, 0, 0, 1, []),
(16, mtef_visitor_source, af_override_horse, 0, 1, []),
(17, mtef_visitor_source, af_override_horse, 0, 1, []),
(18, mtef_visitor_source, af_override_horse, 0, 1, []),
(19, mtef_visitor_source, af_override_horse, 0, 1, []),
(20, mtef_visitor_source, af_override_horse, 0, 1, []),
(21, mtef_visitor_source, af_override_horse, 0, 1, []),
(22, mtef_visitor_source, af_override_horse, 0, 1, []),
(23, mtef_visitor_source, af_override_horse, 0, 1, []),
(24, mtef_visitor_source, af_override_horse, 0, 1, []),
(25, mtef_visitor_source, af_override_horse, 0, 1, []),
(26, mtef_visitor_source, af_override_horse, 0, 1, []),
(27, mtef_visitor_source, af_override_horse, 0, 1, []),
(28, mtef_visitor_source, af_override_horse, 0, 1, []),
(29, mtef_visitor_source, af_override_horse, 0, 1, []),
(30, mtef_visitor_source, af_override_horse, 0, 1, []),
(31, mtef_visitor_source, af_override_horse, 0, 1, []),
],
[
    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (store_current_scene, ":var_0"),
        (scene_set_slot, ":var_0", 0, 1),
        (try_begin),
            (eq, "$sneaked_into_town", 1),
            (call_script, "script_music_set_situation_with_culture", 16384),
        (else_try),
            (eq, "$talk_context", 14),
            (call_script, "script_music_set_situation_with_culture", 512),
        (else_try),
            (call_script, "script_music_set_situation_with_culture", 8192),
        (try_end),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
        (call_script, "script_initialize_tavern_variables"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (gt, "$g_belligerent_drunk_leaving", 0),
        (entry_point_get_position, pos0, 0),
        (agent_get_position, pos1, "$g_belligerent_drunk_leaving"),
        (get_distance_between_positions, ":var_0", pos0, pos1),
        (neg|gt, ":var_0", 150),
    ],
    [
        (agent_fade_out, "$g_belligerent_drunk_leaving"),
        (assign, "$g_belligerent_drunk_leaving", 0),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$g_main_attacker_agent", 0),
            (set_trigger_result, 1),
        (try_end),
    ],
    [
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
        (neg|conversation_screen_is_active),
        (eq, "$talk_context", 14),
        (neg|troop_slot_eq, "trp_hired_assassin", slot_troop_cur_center, "$g_encountered_party"),
        (troop_slot_eq, "trp_belligerent_drunk", slot_troop_cur_center, "$g_encountered_party"),
        (eq, "$drunks_dont_pick_fights", 0),
    ],
    [
        (try_begin),
            (eq, "$g_start_belligerent_drunk_fight", 0),
            (assign, "$g_start_belligerent_drunk_fight", 1),
            (try_for_agents, ":var_0"),
                (agent_get_troop_id, ":var_1", ":var_0"),
                (eq, ":var_1", "trp_belligerent_drunk"),
                (assign, "$g_belligerent_drunk", ":var_0"),
            (try_end),
        (else_try),
            (eq, "$g_start_belligerent_drunk_fight", 1),
            (agent_is_active, "$g_belligerent_drunk"),
            (agent_is_alive, "$g_belligerent_drunk"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos0, ":var_2"),
            (agent_get_position, pos1, "$g_belligerent_drunk"),
            (get_distance_between_positions, ":var_3", pos0, pos1),
            (position_get_z, ":var_4", pos0),
            (position_get_z, ":var_5", pos1),
            (store_sub, ":var_6", ":var_5", ":var_4"),
            (try_begin),
                (neg|gt, ":var_6", 0),
                (val_mul, ":var_6", -1),
            (try_end),
            (store_mul, ":var_7", ":var_6", 3),
            (val_add, ":var_3", ":var_7"),
            (store_random_in_range, ":var_8", 0, 200),
            (store_add, ":var_9", 400, ":var_8"),
            (neg|gt, ":var_3", ":var_9"),
            (call_script, "script_activate_tavern_attackers"),
            (start_mission_conversation, "trp_belligerent_drunk"),
            (assign, "$g_start_belligerent_drunk_fight", 2),
        (try_end),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
        (neg|conversation_screen_is_active),
        (eq, "$talk_context", 14),
        (troop_slot_eq, "trp_hired_assassin", slot_troop_cur_center, "$g_encountered_party"),
    ],
    [
        (try_begin),
            (eq, "$g_start_hired_assassin_fight", 0),
            (assign, "$g_start_hired_assassin_fight", 1),
            (try_for_agents, ":var_0"),
                (agent_get_troop_id, ":var_1", ":var_0"),
                (eq, ":var_1", "trp_hired_assassin"),
                (assign, "$g_hired_assassin", ":var_0"),
            (try_end),
        (else_try),
            (eq, "$g_start_hired_assassin_fight", 1),
            (agent_is_active, "$g_hired_assassin"),
            (agent_is_alive, "$g_hired_assassin"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos0, ":var_2"),
            (agent_get_position, pos1, "$g_hired_assassin"),
            (get_distance_between_positions, ":var_3", pos0, pos1),
            (position_get_z, ":var_4", pos0),
            (position_get_z, ":var_5", pos1),
            (store_sub, ":var_6", ":var_5", ":var_4"),
            (try_begin),
                (neg|gt, ":var_6", 0),
                (val_mul, ":var_6", -1),
            (try_end),
            (store_mul, ":var_7", ":var_6", 3),
            (val_add, ":var_3", ":var_7"),
            (store_random_in_range, ":var_8", 0, 200),
            (store_add, ":var_9", 400, ":var_8"),
            (neg|gt, ":var_3", ":var_9"),
            (call_script, "script_activate_tavern_attackers"),
            (assign, "$g_start_hired_assassin_fight", 2),
        (try_end),
    ]),

    (3.000000, 0.000000, ti_once, 
    [
        (neg|conversation_screen_is_active),
        (eq, "$talk_context", 14),
        (gt, "$g_main_attacker_agent", 0),
        (assign, ":var_0", 0),
        (try_for_agents, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (eq, ":var_2", 1),
            (agent_is_alive, ":var_1"),
            (neg|agent_is_wounded, ":var_1"),
            (val_add, ":var_0", 1),
        (try_end),
        (eq, ":var_0", 0),
        (this_or_next|neg|agent_is_alive, "$g_main_attacker_agent"),
        (agent_is_wounded, "$g_main_attacker_agent"),
    ],
    [
        (mission_enable_talk),
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_position, pos4, ":var_0"),
            (agent_set_scripted_destination, ":var_0", pos4),
        (try_end),
        (party_get_slot, ":var_1", "$g_encountered_party", slot_town_tavernkeeper),
        (start_mission_conversation, ":var_1"),
    ]),

    (3.000000, 0.000000, ti_once, 
    [
        (neg|conversation_screen_is_active),
        (eq, "$talk_context", 14),
        (gt, "$g_main_attacker_agent", 0),
        (main_hero_fallen),
    ],
    [
        (jump_to_menu, "mnu_lost_tavern_duel"),
        (finish_mission, 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (neg|conversation_screen_is_active),
        (eq, "$talk_context", 14),
        (gt, "$g_main_attacker_agent", 0),
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (is_between, ":var_1", "itm_darts", "itm_torch"),
        (neg|eq, ":var_1", "itm_light_throwing_axes_melee"),
        (neg|eq, ":var_1", "itm_throwing_axes_melee"),
        (neg|eq, ":var_1", "itm_heavy_throwing_axes_melee"),
    ],
    [
        (party_get_slot, ":var_0", "$g_encountered_party", slot_town_tavernkeeper),
        (start_mission_conversation, ":var_0"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (gt, "$g_main_attacker_agent", 0),
    ],
    [
        (agent_get_wielded_item, ":var_0", "$g_main_attacker_agent", 0),
        (val_max, "$g_attacker_drawn_weapon", ":var_0"),
        (call_script, "script_neutral_behavior_in_fight"),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"conversation_encounter", 0, -1, 
"Conversation_encounter",
[(0, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(1, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(2, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(3, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(4, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(5, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(6, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(7, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(8, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(9, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(10, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(11, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(12, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(13, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(14, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(15, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(16, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(17, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(18, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(19, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(20, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(21, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(22, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(23, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(24, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(25, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(26, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(27, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(28, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(29, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(30, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
(31, mtef_visitor_source, af_override_fullhelm, 0, 1, []),
],
[

],),

(
"town_center", 0, -1, 
"Default_town_visit",
[(0, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(1, mtef_scene_source|mtef_team_0, 0, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(4, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(5, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(6, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(7, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(8, mtef_visitor_source, af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_horse, 0, 1, []),
(10, mtef_visitor_source, af_override_horse, 0, 1, []),
(11, mtef_visitor_source, af_override_horse, 0, 1, []),
(12, mtef_visitor_source, af_override_horse, 0, 1, []),
(13, mtef_visitor_source, 0, 0, 1, []),
(14, mtef_scene_source, 0, 0, 1, []),
(15, mtef_scene_source, 0, 0, 1, []),
(16, mtef_visitor_source, af_override_horse, 0, 1, []),
(17, mtef_visitor_source, af_override_horse, 0, 1, []),
(18, mtef_visitor_source, af_override_horse, 0, 1, []),
(19, mtef_visitor_source, af_override_horse, 0, 1, []),
(20, mtef_visitor_source, af_override_horse, 0, 1, []),
(21, mtef_visitor_source, af_override_horse, 0, 1, []),
(22, mtef_visitor_source, af_override_horse, 0, 1, []),
(23, mtef_visitor_source, af_override_horse, 0, 1, []),
(24, mtef_visitor_source, af_override_horse, 0, 1, []),
(25, mtef_visitor_source, af_override_horse, 0, 1, []),
(26, mtef_visitor_source, af_override_horse, 0, 1, []),
(27, mtef_visitor_source, af_override_horse, 0, 1, []),
(28, mtef_visitor_source, af_override_horse, 0, 1, []),
(29, mtef_visitor_source, af_override_horse, 0, 1, []),
(30, mtef_visitor_source, af_override_horse, 0, 1, []),
(31, mtef_visitor_source, af_override_horse, 0, 1, []),
(32, mtef_visitor_source, af_override_horse, 0, 1, []),
(33, mtef_visitor_source, af_override_horse, 0, 1, []),
(34, mtef_visitor_source, af_override_horse, 0, 1, []),
(35, mtef_visitor_source, af_override_horse, 0, 1, []),
(36, mtef_visitor_source, af_override_horse, 0, 1, []),
(37, mtef_visitor_source, af_override_horse, 0, 1, []),
(38, mtef_visitor_source, af_override_horse, 0, 1, []),
(39, mtef_visitor_source, af_override_horse, 0, 1, []),
(40, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (0.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_cf_move_ship", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_cf_move_ship_d", 0),
    ],
    [
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_init_town_agent", ":var_0"),
        (try_begin),
            (this_or_next|eq, "$talk_context", 19),
            (eq, "$talk_context", 18),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (troop_slot_eq, ":var_1", 155, 1),
            (agent_set_team, ":var_0", 0),
            (agent_ai_set_aggressiveness, ":var_0", 5),
            (troop_set_slot, ":var_1", 155, 0),
            (try_begin),
                (troop_slot_eq, ":var_1", slot_troop_mission_participation, 3),
                (agent_get_position, pos1, ":var_0"),
                (agent_set_scripted_destination, ":var_0", pos1),
            (try_end),
        (try_end),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_main_attacker_agent", 0),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_mt_mode", 0),
            (store_current_scene, ":var_0"),
            (scene_set_slot, ":var_0", 0, 1),
        (try_end),
        (call_script, "script_init_town_walker_agents"),
        (try_begin),
            (eq, "$sneaked_into_town", 1),
            (call_script, "script_music_set_situation_with_culture", 16384),
        (else_try),
            (try_begin),
                (eq, "$current_town", "p_town_14"),
                (music_set_situation, 8192),
                (play_track, "track_singal", 1),
            (else_try),
                (call_script, "script_music_set_situation_with_culture", 8192),
            (try_end),
        (try_end),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$g_mt_mode", 0),
            (set_trigger_result, 1),
        (else_try),
            (eq, "$g_mt_mode", 1),
            (display_message, "str_cant_use_inventory_disguised"),
        (else_try),
            (display_message, "str_cant_use_inventory_now"),
        (try_end),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (this_or_next|eq, "$talk_context", 19),
            (eq, "$talk_context", 18),
            (display_message, "str_cannot_leave_now"),
        (else_try),
            (this_or_next|eq, "$g_mt_mode", 0),
            (eq, "$g_mt_mode", 1),
            (mission_enable_talk),
            (set_trigger_result, 1),
        (else_try),
            (display_message, "str_cannot_leave_now"),
        (try_end),
    ],
    [
    ]),

    (ti_on_leave_area, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$g_defending_against_siege", 0),
            (assign, "$g_leave_town", 1),
        (try_end),
    ],
    [
        (try_begin),
            (eq, "$talk_context", 19),
            (call_script, "script_deduct_casualties_from_garrison"),
            (jump_to_menu, "mnu_sneak_into_town_caught_dispersed_guards"),
        (try_end),
        (mission_enable_talk),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (party_slot_eq, "$current_town", slot_party_type, 3),
        (call_script, "script_town_init_doors", 0),
        (try_begin),
            (eq, "$town_nighttime", 0),
            (play_sound, "snd_town_ambiance", 2),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_tick_town_walkers"),
    ],
    [
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_center_ambiance_sounds"),
    ],
    [
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (this_or_next|eq, "$talk_context", 18),
        (eq, "$talk_context", 19),
    ],
    [
        (call_script, "script_neutral_behavior_in_fight"),
        (mission_disable_talk),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
        (eq, "$talk_context", 19),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (assign, reg6, ":var_0"),
        (call_script, "script_activate_town_guard"),
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos4, ":var_0"),
        (try_for_range, ":var_1", "trp_npc_adonja", "trp_heroes_end"),
            (troop_slot_ge, ":var_1", slot_troop_mission_participation, 2),
            (str_store_troop_name, s4, ":var_1"),
            (display_message, "str_s4_joins_prison_break"),
            (store_current_scene, ":var_2"),
            (modify_visitors_at_site, ":var_2"),
            (store_current_scene, ":var_2"),
            (modify_visitors_at_site, ":var_2"),
            (add_visitors_to_current_scene, 24, ":var_1", 1, 0, 0),
            (troop_set_slot, ":var_1", 155, 1),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (main_hero_fallen, 0),
    ],
    [
        (try_begin),
            (this_or_next|eq, "$talk_context", 18),
            (eq, "$talk_context", 19),
            (call_script, "script_deduct_casualties_from_garrison"),
            (jump_to_menu, "mnu_captivity_start_castle_defeat"),
            (assign, ":var_0", "trp_heroes_end"),
            (try_for_range, ":var_1", "trp_npc_adonja", ":var_0"),
                (troop_set_slot, ":var_1", slot_troop_mission_participation, 0),
            (try_end),
            (mission_enable_talk),
            (finish_mission, 0),
        (else_try),
            (set_trigger_result, 1),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (eq, "$talk_context", 19),
        (neg|main_hero_fallen, 0),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (all_enemies_defeated),
    ],
    [
        (call_script, "script_deduct_casualties_from_garrison"),
        (try_for_agents, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (troop_slot_ge, ":var_1", slot_troop_mission_participation, 2),
            (try_begin),
                (agent_is_alive, ":var_0"),
                (troop_set_slot, ":var_1", slot_troop_mission_participation, 4),
            (else_try),
                (troop_set_slot, ":var_1", slot_troop_mission_participation, 5),
            (try_end),
        (try_end),
        (jump_to_menu, "mnu_sneak_into_town_caught_ran_away"),
        (mission_enable_talk),
        (finish_mission, 0),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_get_troop_id, ":var_2", ":var_0"),
        (agent_get_troop_id, ":var_3", ":var_1"),
        (try_begin),
            (this_or_next|eq, ":var_2", "trp_sarleon_prison_guard"),
            (this_or_next|eq, ":var_2", "trp_rav_prison_guard"),
            (this_or_next|eq, ":var_2", "trp_dshar_prison_guard"),
            (this_or_next|eq, ":var_2", "trp_fierd_prison_guard"),
            (eq, ":var_2", "trp_empire_prison_guard"),
            (eq, ":var_3", "trp_player"),
            (display_message, "@You got the keys to the dungeon."),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"village_center", 0, -1, 
"village_center",
[(0, mtef_scene_source|mtef_team_0, 0, 0, 1, []),
(1, mtef_scene_source|mtef_team_0, 0, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(5, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_visitor_source, af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_horse, 0, 1, []),
(10, mtef_visitor_source, af_override_horse, 0, 1, []),
(11, mtef_visitor_source, af_override_horse, 0, 1, []),
(12, mtef_visitor_source, af_override_horse, 0, 1, []),
(13, mtef_visitor_source, 0, 0, 1, []),
(14, mtef_visitor_source, 0, 0, 1, []),
(15, mtef_visitor_source, 0, 0, 1, []),
(16, mtef_visitor_source, af_override_horse, 0, 1, []),
(17, mtef_visitor_source, af_override_horse, 0, 1, []),
(18, mtef_visitor_source, af_override_horse, 0, 1, []),
(19, mtef_visitor_source, af_override_horse, 0, 1, []),
(20, mtef_visitor_source, af_override_horse, 0, 1, []),
(21, mtef_visitor_source, af_override_horse, 0, 1, []),
(22, mtef_visitor_source, af_override_horse, 0, 1, []),
(23, mtef_visitor_source, af_override_horse, 0, 1, []),
(24, mtef_visitor_source, af_override_horse, 0, 1, []),
(25, mtef_visitor_source, af_override_horse, 0, 1, []),
(26, mtef_visitor_source, af_override_horse, 0, 1, []),
(27, mtef_visitor_source, af_override_horse, 0, 1, []),
(28, mtef_visitor_source, af_override_horse, 0, 1, []),
(29, mtef_visitor_source, af_override_horse, 0, 1, []),
(30, mtef_visitor_source, af_override_horse, 0, 1, []),
(31, mtef_visitor_source, af_override_horse, 0, 1, []),
(32, mtef_visitor_source, af_override_horse, 0, 1, []),
(33, mtef_visitor_source, af_override_horse, 0, 1, []),
(34, mtef_visitor_source, af_override_horse, 0, 1, []),
(35, mtef_visitor_source, af_override_horse, 0, 1, []),
(36, mtef_visitor_source, af_override_horse, 0, 1, []),
(37, mtef_visitor_source, af_override_horse, 0, 1, []),
(38, mtef_visitor_source, af_override_horse, 0, 1, []),
(39, mtef_visitor_source, af_override_horse, 0, 1, []),
(40, mtef_visitor_source, af_override_horse, 0, 1, []),
(41, mtef_visitor_source, af_override_horse, 0, 1, []),
(42, mtef_visitor_source, af_override_horse, 0, 1, []),
(43, mtef_visitor_source, af_override_horse, 0, 1, []),
(44, mtef_visitor_source, af_override_horse, 0, 1, []),
(45, mtef_visitor_source, af_override_horse, 0, 1, []),
(46, mtef_visitor_source, af_override_horse, 0, 1, []),
(47, mtef_visitor_source, af_override_horse, 0, 1, []),
],
[
    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (store_current_scene, ":var_0"),
        (scene_set_slot, ":var_0", 0, 1),
        (call_script, "script_init_town_walker_agents"),
        (call_script, "script_music_set_situation_with_culture", 67108864),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (check_quest_active, "qst_hunt_down_fugitive"),
            (neg|check_quest_succeeded, "qst_hunt_down_fugitive"),
            (neg|check_quest_failed, "qst_hunt_down_fugitive"),
            (quest_slot_eq, "qst_hunt_down_fugitive", 11, 1),
            (try_begin),
                (call_script, "script_cf_troop_agent_is_alive", "trp_fugitive"),
                (call_script, "script_fail_quest", "qst_hunt_down_fugitive"),
            (else_try),
                (call_script, "script_succeed_quest", "qst_hunt_down_fugitive"),
            (try_end),
        (try_end),
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_on_leave_area, 0.000000, 0.000000, 
    [
        (try_begin),
            (assign, "$g_leave_town", 1),
        (try_end),
    ],
    [
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_tick_town_walkers"),
    ],
    [
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_center_ambiance_sounds"),
    ],
    [
    ]),

    (1.000000, 0.000000, ti_once, 
    [
        (check_quest_active, "qst_hunt_down_fugitive"),
        (neg|check_quest_succeeded, "qst_hunt_down_fugitive"),
        (neg|check_quest_failed, "qst_hunt_down_fugitive"),
        (quest_slot_eq, "qst_hunt_down_fugitive", 11, 1),
        (assign, ":var_0", 0),
        (try_begin),
            (call_script, "script_cf_troop_agent_is_alive", "trp_fugitive"),
        (else_try),
            (assign, ":var_0", 1),
        (try_end),
        (this_or_next|main_hero_fallen),
        (eq, ":var_0", 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (jump_to_menu, "mnu_village_hunt_down_fugitive_defeated"),
            (call_script, "script_fail_quest", "qst_hunt_down_fugitive"),
            (finish_mission, 4),
        (else_try),
            (call_script, "script_change_player_relation_with_center", "$current_town", -2),
            (call_script, "script_succeed_quest", "qst_hunt_down_fugitive"),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"bandits_at_night", 0, -1, 
"Default_town_visit",
[(0, mtef_scene_source|mtef_team_0, af_override_horse, 16, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(1, mtef_scene_source|mtef_team_0, 0, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(5, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_scene_source, af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_horse, 0, 1, []),
(10, mtef_visitor_source, af_override_horse, 0, 1, []),
(11, mtef_visitor_source, af_override_horse, 16, 1, []),
(12, mtef_visitor_source, af_override_horse, 0, 1, []),
(13, mtef_scene_source, 0, 0, 1, []),
(14, mtef_scene_source, 0, 0, 1, []),
(15, mtef_scene_source, 0, 0, 1, []),
(16, mtef_visitor_source, af_override_horse, 0, 1, []),
(17, mtef_visitor_source, af_override_horse, 0, 1, []),
(18, mtef_visitor_source, af_override_horse, 0, 1, []),
(19, mtef_visitor_source, af_override_horse, 0, 1, []),
(20, mtef_visitor_source, af_override_horse, 0, 1, []),
(21, mtef_visitor_source, af_override_horse, 0, 1, []),
(22, mtef_visitor_source, af_override_horse, 0, 1, []),
(23, mtef_visitor_source, af_override_horse, 0, 1, []),
(24, mtef_visitor_source, af_override_horse, 0, 1, []),
(25, mtef_visitor_source, af_override_horse, 0, 1, []),
(26, mtef_visitor_source, af_override_horse, 0, 1, []),
(27, mtef_visitor_source, af_override_horse, 16, 1, []),
(28, mtef_visitor_source, af_override_horse, 16, 1, []),
(29, mtef_visitor_source, af_override_horse, 0, 1, []),
(30, mtef_visitor_source, af_override_horse, 0, 1, []),
(31, mtef_visitor_source, af_override_horse, 0, 1, []),
(32, mtef_visitor_source, af_override_horse, 0, 1, []),
(33, mtef_visitor_source, af_override_horse, 0, 1, []),
(34, mtef_visitor_source, af_override_horse, 0, 1, []),
(35, mtef_visitor_source, af_override_horse, 0, 1, []),
(36, mtef_visitor_source, af_override_horse, 0, 1, []),
(37, mtef_visitor_source, af_override_horse, 0, 1, []),
(38, mtef_visitor_source, af_override_horse, 0, 1, []),
(39, mtef_visitor_source, af_override_horse, 0, 1, []),
(40, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (neg|eq, ":var_1", "trp_player"),
        (agent_set_team, ":var_0", 1),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cannot_leave_now"),
    ],
    [
    ]),

    (ti_on_leave_area, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$g_defending_against_siege", 0),
            (assign, "$g_leave_town", 1),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 4096),
        (set_party_battle_mode),
        (party_slot_eq, "$current_town", slot_party_type, 3),
        (call_script, "script_town_init_doors", 0),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 5),
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (jump_to_menu, "mnu_town_bandits_failed"),
        (else_try),
            (jump_to_menu, "mnu_town_bandits_succeeded"),
        (try_end),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"village_training", 1, -1, 
"village_training",
[(2, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff, itm_practice_boots]),
(4, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff, itm_practice_boots]),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_train_peasants_against_bandits_training_succeeded", 0),
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (question_box, "str_give_up_fight"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (neg|main_hero_fallen),
            (assign, "$g_train_peasants_against_bandits_training_succeeded", 1),
        (try_end),
        (finish_mission),
    ]),


],),

(
"visit_town_castle", 0, -1, 
"You_enter_the_halls_of_the_lord.",
[(0, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(1, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(5, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_visitor_source, af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_horse, 0, 1, []),
(10, mtef_scene_source, af_override_horse, 0, 1, []),
(11, mtef_scene_source, af_override_horse, 0, 1, []),
(12, mtef_visitor_source, af_override_horse, 0, 1, []),
(13, mtef_visitor_source, 0, 0, 1, []),
(14, mtef_visitor_source, 0, 0, 1, []),
(15, mtef_visitor_source, 0, 0, 1, []),
(16, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(17, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(18, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(19, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(20, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(21, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(22, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(23, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(24, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(25, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(26, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(27, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(28, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(29, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(30, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(31, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_init_town_agent", ":var_0"),
        (try_begin),
            (eq, "$pop_teleport_player_to_pos59", 1),
            (neg|agent_is_non_player, ":var_0"),
            (agent_set_position, ":var_0", pos59),
        (try_end),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
        (eq, "$pop_teleport_player_to_pos59", 1),
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (is_between, ":var_1", "trp_town_1_seneschal", "trp_town_1_arena_master"),
            (assign, ":var_2", ":var_1"),
        (try_end),
        (start_mission_conversation, ":var_2"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (neg|eq, "$talk_context", 18),
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_on_leave_area, 0.000000, 0.000000, 
    [
        (eq, "$talk_context", 18),
    ],
    [
        (display_message, "str_leaving_area_during_prison_break"),
        (set_jump_mission, "mt_sneak_caught_fight"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$talk_context", 1),
            (try_begin),
                (store_faction_of_party, ":var_0", "$current_town"),
                (faction_slot_eq, ":var_0", slot_faction_ai_state, 6),
                (faction_slot_eq, ":var_0", slot_faction_ai_object, "$current_town"),
                (call_script, "script_music_set_situation_with_culture", 16777216),
            (else_try),
                (try_begin),
                    (eq, "$current_town", "p_castle_noldor"),
                    (music_set_situation, 33554432),
                    (play_track, "track_lords_hall_noldor", 1),
                (else_try),
                    (call_script, "script_music_set_situation_with_culture", 33554432),
                (try_end),
            (try_end),
        (else_try),
            (call_script, "script_music_set_situation_with_culture", 0),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"visit_town_castle_ghostlady", 0, -1, 
"You_enter_the_halls_of_the_lord.",
[(0, mtef_scene_source|mtef_team_0, af_override_head|af_override_horse, 0, 1, []),
(1, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(5, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_visitor_source, af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_horse, 0, 1, []),
(10, mtef_scene_source, af_override_horse, 0, 1, []),
(11, mtef_scene_source, af_override_horse, 0, 1, []),
(12, mtef_visitor_source, af_override_horse, 0, 1, []),
(13, mtef_visitor_source, 0, 0, 1, []),
(14, mtef_visitor_source, 0, 0, 1, []),
(15, mtef_visitor_source, 0, 0, 1, []),
(16, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(17, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(18, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(19, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(20, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(21, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(22, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(23, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(24, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(25, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(26, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(27, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(28, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(29, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(30, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(31, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_init_town_agent", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (neg|eq, "$talk_context", 18),
        (try_begin),
            (check_quest_active, "qst_ghost_lady"),
            (neg|check_quest_succeeded, "qst_ghost_lady"),
            (neg|check_quest_failed, "qst_ghost_lady"),
            (quest_slot_eq, "qst_ghost_lady", 11, 4),
            (try_begin),
                (call_script, "script_cf_troop_agent_is_alive", "trp_ghost_quest_castle_scribe"),
                (quest_set_slot, "qst_ghost_lady", 11, 5),
                (str_store_string, s60, "@You have escaped from the fight with the scribe, talk to the Ghost Lady again."),
                (add_quest_note_from_sreg, "qst_ghost_lady", 0, 60, 0),
            (else_try),
                (quest_set_slot, "qst_ghost_lady", 11, 6),
            (try_end),
        (try_end),
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_on_leave_area, 0.000000, 0.000000, 
    [
        (eq, "$talk_context", 18),
    ],
    [
        (display_message, "str_leaving_area_during_prison_break"),
        (set_jump_mission, "mt_sneak_caught_fight"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$talk_context", 1),
            (try_begin),
                (store_faction_of_party, ":var_0", "$current_town"),
                (faction_slot_eq, ":var_0", slot_faction_ai_state, 6),
                (faction_slot_eq, ":var_0", slot_faction_ai_object, "$current_town"),
                (call_script, "script_music_set_situation_with_culture", 16777216),
            (else_try),
                (try_begin),
                    (eq, "$current_town", "p_castle_noldor"),
                    (music_set_situation, 33554432),
                    (play_track, "track_lords_hall_noldor", 1),
                (else_try),
                    (call_script, "script_music_set_situation_with_culture", 33554432),
                (try_end),
            (try_end),
        (else_try),
            (call_script, "script_music_set_situation_with_culture", 0),
        (try_end),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
        (check_quest_active, "qst_ghost_lady"),
        (neg|check_quest_succeeded, "qst_ghost_lady"),
        (neg|check_quest_failed, "qst_ghost_lady"),
        (quest_slot_eq, "qst_ghost_lady", 11, 4),
        (assign, ":var_0", 0),
        (try_begin),
            (call_script, "script_cf_troop_agent_is_alive", "trp_ghost_quest_castle_scribe"),
        (else_try),
            (assign, ":var_0", 1),
        (try_end),
        (this_or_next|main_hero_fallen),
        (eq, ":var_0", 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (jump_to_menu, "mnu_ghostlady_knocked_out"),
            (quest_set_slot, "qst_ghost_lady", 11, 5),
            (str_store_string, s60, "@You have been knocked out by the scribe, talk to the Ghost Lady again."),
            (add_quest_note_from_sreg, "qst_ghost_lady", 0, 60, 0),
            (str_clear, s60),
            (add_quest_note_from_sreg, "qst_ghost_lady", 1, 60, 0),
            (add_quest_note_from_sreg, "qst_ghost_lady", 2, 60, 0),
            (add_quest_note_from_sreg, "qst_ghost_lady", 3, 60, 0),
            (finish_mission, 4),
        (else_try),
            (quest_set_slot, "qst_ghost_lady", 11, 6),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"grandmaster_ambush", 2, -1, 
"Grandmaster_quest_starts_here...",
[(0, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(6, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(7, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (neg|eq, "$g_battle_won", 1),
            (display_message, "str_cannot_leave_now"),
        (else_try),
            (finish_mission, 0),
            (jump_to_menu, "mnu_grandmaster_ambush_won"),
        (try_end),
    ],
    [
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (call_script, "script_music_set_situation_with_culture", 4096),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
    ],
    [
        (jump_to_menu, "mnu_grandmaster_ambush_won"),
        (finish_mission, 1),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (assign, "$pin_player_fallen", 1),
        (display_message, "@You have been knocked out!"),
        (set_mission_result, -1),
        (finish_mission, 0),
        (jump_to_menu, "mnu_grandmaster_ambush_lost"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"back_alley_kill_local_merchant", 2, -1, 
"You_enter_the_back_alley",
[(0, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(3, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cannot_leave_now"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 4096),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 1),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (assign, ":var_1", 0),
        (assign, ":var_3", -1),
        (assign, ":var_4", -1),
        (try_for_agents, ":var_5"),
            (agent_get_troop_id, ":var_6", ":var_5"),
            (try_begin),
                (eq, ":var_6", "trp_local_merchant"),
                (store_agent_hit_points, ":var_1", ":var_5"),
                (assign, ":var_3", ":var_5"),
            (else_try),
                (eq, ":var_6", "trp_player"),
                (store_agent_hit_points, ":var_2", ":var_5"),
                (assign, ":var_4", ":var_5"),
            (try_end),
        (try_end),
        (ge, ":var_4", 0),
        (ge, ":var_3", 0),
        (agent_is_alive, ":var_4"),
        (agent_is_alive, ":var_3"),
        (is_between, ":var_1", 1, 30),
        (gt, ":var_2", 50),
        (start_mission_conversation, "trp_local_merchant"),
    ],
    [
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (assign, ":var_0", 0),
        (try_begin),
            (call_script, "script_cf_troop_agent_is_alive", "trp_local_merchant"),
        (else_try),
            (assign, ":var_0", 1),
        (try_end),
        (this_or_next|main_hero_fallen),
        (eq, ":var_0", 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (call_script, "script_fail_quest", "qst_kill_local_merchant"),
        (else_try),
            (call_script, "script_change_player_relation_with_center", "$current_town", -4),
            (call_script, "script_succeed_quest", "qst_kill_local_merchant"),
        (try_end),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"back_alley_revolt", 2, 8, 
"You_lead_your_men_to_battle.",
[(0, mtef_team_0|mtef_use_exact_number, af_override_weapons|af_override_head|af_override_horse, 16, 4, [itm_quarter_staff]),
(3, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (question_box, "str_do_you_want_to_retreat"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (jump_to_menu, "mnu_collect_taxes_failed"),
        (finish_mission),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cannot_leave_now"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 1024),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (jump_to_menu, "mnu_collect_taxes_failed"),
        (else_try),
            (jump_to_menu, "mnu_collect_taxes_rebels_killed"),
        (try_end),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"lead_charge", 65538, 8, 
"You_lead_your_men_to_battle.",
[(1, mtef_defenders|mtef_team_0, 0, 16, 12, []),
(0, mtef_defenders|mtef_team_0, 0, 16, 0, []),
(4, mtef_attackers|mtef_team_1, 0, 16, 12, []),
(4, mtef_attackers|mtef_team_1, 0, 16, 0, []),
],
[
    (ti_on_item_unwielded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_is_non_player, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_is_human, ":var_0"),
        (item_get_type, ":var_2", ":var_1"),
        (this_or_next|is_between, ":var_2", 2, 5),
        (is_between, ":var_2", 8, 11),
        (agent_has_item_equipped, ":var_0", ":var_1"),
        (agent_slot_eq, ":var_0", 246, 0),
        (agent_get_ammo, ":var_3", ":var_0", 1),
        (this_or_next|neg|eq, ":var_2", 10),
        (neg|eq, ":var_3", 0),
        (agent_set_slot, ":var_0", 246, ":var_1"),
        (agent_set_slot, ":var_0", 245, ":var_3"),
    ]),

    (ti_on_item_wielded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_is_non_player, ":var_0"),
        (item_get_type, ":var_2", ":var_1"),
        (this_or_next|is_between, ":var_2", 2, 5),
        (is_between, ":var_2", 8, 11),
        (agent_get_slot, ":var_3", ":var_0", 246),
        (try_begin),
            (gt, ":var_3", 0),
            (neg|eq, ":var_1", ":var_3"),
            (assign, ":var_4", 3),
            (try_begin),
                (eq, ":var_2", 8),
                (assign, ":var_4", 6),
            (try_end),
            (agent_set_slot, ":var_0", 247, ":var_4"),
        (else_try),
            (agent_set_slot, ":var_0", 247, 0),
        (try_end),
        (agent_get_slot, ":var_5", ":var_0", 245),
        (agent_get_ammo, ":var_6", ":var_0"),
        (try_begin),
            (ge, ":var_5", 0),
            (ge, ":var_6", 0),
            (agent_set_ammo, ":var_0", ":var_5"),
        (try_end),
        (agent_set_slot, ":var_0", 245, -1),
    ]),

    (ti_on_item_wielded, 1.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_is_non_player, ":var_0"),
        (item_get_type, ":var_2", ":var_1"),
        (this_or_next|is_between, ":var_2", 2, 5),
        (is_between, ":var_2", 8, 11),
        (agent_get_slot, ":var_3", ":var_0", 246),
        (try_begin),
            (gt, ":var_3", 0),
            (neg|eq, ":var_1", ":var_3"),
            (agent_has_item_equipped, ":var_0", ":var_3"),
            (agent_unequip_item, ":var_0", ":var_3"),
            (agent_force_rethink, ":var_0"),
        (else_try),
            (agent_set_slot, ":var_0", 247, 0),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_agent_reassign_team", ":var_0"),
        (assign, ":var_1", 5000),
        (agent_get_troop_id, ":var_2", ":var_0"),
        (store_character_level, ":var_3", ":var_2"),
        (val_mul, ":var_3", 70),
        (val_add, ":var_1", ":var_3"),
        (store_random_in_range, ":var_4", 1000, 3000),
        (val_add, ":var_1", ":var_4"),
        (agent_get_party_id, ":var_5", ":var_0"),
        (party_get_morale, ":var_6", ":var_5"),
        (store_sub, ":var_7", ":var_6", 70),
        (val_mul, ":var_7", 30),
        (val_add, ":var_1", ":var_7"),
        (agent_set_slot, ":var_0", slot_agent_courage_score, ":var_1"),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_set_slot, ":var_0", 46, -1),
        (agent_get_division, ":var_1", ":var_0"),
        (agent_set_slot, ":var_0", 248, ":var_1"),
        (assign, ":var_2", 0),
        (try_for_range, ":var_3", 0, 4),
            (agent_get_item_slot, ":var_4", ":var_0", ":var_3"),
            (gt, ":var_4", -1),
            (item_get_type, ":var_5", ":var_4"),
            (try_begin),
                (eq, ":var_5", 4),
                (item_get_slot, ":var_6", ":var_4", 201),
                (store_and, ":var_7", ":var_6", 2147483648),
                (gt, ":var_7", 0),
                (item_get_slot, ":var_8", ":var_4", 17),
                (ge, ":var_8", 200),
                (assign, ":var_2", 1),
            (try_end),
        (try_end),
        (agent_set_slot, ":var_0", 51, ":var_2"),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (try_begin),
            (neg|agent_is_human, ":var_0"),
            (agent_get_rider, ":var_1", ":var_0"),
            (ge, ":var_1", 0),
            (agent_is_active, ":var_1"),
            (agent_is_alive, ":var_1"),
            (agent_is_non_player, ":var_1"),
        (else_try),
            (assign, ":var_1", -1),
        (try_end),
        (agent_set_slot, ":var_0", 45, ":var_1"),
    ]),

    (ti_on_agent_dismount, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_is_alive, ":var_0"),
        (agent_is_non_player, ":var_0"),
        (assign, ":var_2", 0),
        (try_for_range, ":var_3", 0, 4),
            (agent_get_item_slot, ":var_4", ":var_0", ":var_3"),
            (gt, ":var_4", 0),
            (item_get_type, ":var_5", ":var_4"),
            (this_or_next|eq, ":var_5", 8),
            (this_or_next|eq, ":var_5", 9),
            (this_or_next|eq, ":var_5", 16),
            (eq, ":var_5", 17),
            (assign, ":var_2", 1),
            (assign, ":var_6", 0),
        (try_end),
        (try_begin),
            (eq, ":var_2", 1),
            (agent_set_division, ":var_0", 1),
            (agent_set_slot, ":var_0", 46, 1),
        (else_try),
            (agent_set_division, ":var_0", 0),
            (agent_set_slot, ":var_0", 46, 0),
        (try_end),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (neg|agent_is_human, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 45),
        (ge, ":var_1", 0),
        (agent_is_active, ":var_1"),
        (agent_is_alive, ":var_1"),
        (agent_is_non_player, ":var_1"),
        (agent_set_division, ":var_1", 0),
        (agent_set_slot, ":var_1", 46, 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_active, ":var_0"),
            (agent_slot_ge, ":var_0", 46, 0),
            (agent_is_alive, ":var_0"),
            (agent_get_division, ":var_1", ":var_0"),
            (neg|agent_slot_eq, ":var_0", 46, ":var_1"),
            (agent_get_slot, ":var_2", ":var_0", 46),
            (agent_set_division, ":var_0", ":var_2"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (try_begin),
            (ge, ":var_0", 0),
            (neg|agent_is_ally, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_troop_id, ":var_3", ":var_0"),
            (party_add_members, "p_total_enemy_casualties", ":var_3", 1),
            (eq, ":var_2", 1),
            (party_wound_members, "p_total_enemy_casualties", ":var_3", 1),
        (try_end),
        (call_script, "script_apply_death_effect_on_courage_scores", ":var_0", ":var_1"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$pop_camera_on", 0),
        (assign, "$pop_camera_mouse_center_x", 500),
        (assign, "$pop_camera_mouse_center_y", 375),
        (assign, "$pop_camera_mouse_x", "$pop_camera_mouse_center_x"),
        (assign, "$pop_camera_mouse_y", "$pop_camera_mouse_center_y"),
        (assign, "$pop_camera_mouse_counter", 0),
    ]),

    (0.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (eq, "$pop_camera_on", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (position_get_x, ":var_1", pos1),
        (position_get_y, ":var_2", pos1),
        (init_position, pos23),
        (position_set_x, pos23, ":var_1"),
        (position_set_y, pos23, ":var_2"),
        (position_set_z_to_ground_level, pos23),
        (position_move_z, pos23, 250),
        (mission_cam_set_mode, 1, 0, 0),
        (mission_cam_set_position, pos23),
        (assign, "$pop_camera_rotx", 0),
        (assign, "$pop_camera_on", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_is_down, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_is_down, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_is_down, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (game_key_is_down, gk_move_right),
    ],
    [
        (mission_cam_get_position, pos23),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_forward),
            (game_key_is_down, gk_move_forward),
            (assign, ":var_1", 10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_backward),
            (game_key_is_down, gk_move_backward),
            (assign, ":var_1", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_left),
            (game_key_is_down, gk_move_left),
            (assign, ":var_0", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_right),
            (game_key_is_down, gk_move_right),
            (assign, ":var_0", 10),
        (try_end),
        (position_move_x, pos23, ":var_0"),
        (position_move_y, pos23, ":var_1"),
        (mission_cam_set_position, pos23),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (neg|is_presentation_active, "prsnt_battle"),
        (mouse_get_position, pos1),
        (set_fixed_point_multiplier, 1000),
        (position_get_x, reg1, pos1),
        (position_get_y, reg2, pos1),
        (this_or_next|neg|eq, reg1, "$pop_camera_mouse_center_x"),
        (neg|eq, reg2, "$pop_camera_mouse_center_y"),
    ],
    [
        (assign, ":var_0", 1),
        (try_begin),
            (eq, reg1, "$pop_camera_mouse_x"),
            (eq, reg2, "$pop_camera_mouse_y"),
            (val_add, "$pop_camera_mouse_counter", 1),
            (try_begin),
                (gt, "$pop_camera_mouse_counter", 30),
                (assign, "$pop_camera_mouse_center_x", reg1),
                (assign, "$pop_camera_mouse_center_y", reg2),
                (assign, "$pop_camera_mouse_counter", 0),
            (try_end),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
        (assign, "$pop_camera_mouse_counter", 0),
        (assign, "$pop_camera_mouse_x", reg1),
        (assign, "$pop_camera_mouse_y", reg2),
        (mission_cam_get_position, pos23),
        (store_sub, ":var_1", "$pop_camera_mouse_center_x", reg1),
        (store_sub, ":var_2", reg2, "$pop_camera_mouse_center_y"),
        (try_for_range, ":var_3", 0, 2),
            (try_begin),
                (eq, ":var_3", 1),
                (assign, ":var_1", ":var_2"),
            (try_end),
            (this_or_next|neg|ge, ":var_1", -2),
            (gt, ":var_1", 2),
            (assign, ":var_4", 1),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_4", -1),
            (try_end),
            (val_abs, ":var_1"),
            (val_sub, ":var_1", 2),
            (convert_to_fixed_point, ":var_1"),
            (store_sqrt, ":var_1", ":var_1"),
            (convert_from_fixed_point, ":var_1"),
            (val_clamp, ":var_1", 1, 10),
            (val_mul, ":var_1", ":var_4"),
            (try_begin),
                (eq, ":var_3", 0),
                (store_mul, ":var_5", "$pop_camera_rotx", -1),
                (position_rotate_x, pos23, ":var_5"),
                (position_rotate_z, pos23, ":var_1"),
                (position_rotate_x, pos23, "$pop_camera_rotx"),
            (else_try),
                (position_rotate_x, pos23, ":var_1"),
                (val_add, "$pop_camera_rotx", ":var_1"),
            (try_end),
        (try_end),
        (mission_cam_set_position, pos23),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (try_begin),
            (store_mission_timer_a, ":var_1"),
            (gt, ":var_1", 20),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 1),
        (try_end),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (team_set_relation, 0, 2, 1),
        (team_set_relation, 1, 3, 1),
        (call_script, "script_place_player_banner_near_inventory_bms"),
        (party_clear, "p_routed_enemies"),
        (assign, "$g_latest_order_1", 1),
        (assign, "$g_latest_order_2", 1),
        (assign, "$g_latest_order_3", 1),
        (assign, "$g_latest_order_4", 1),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (assign, "$defender_reinforcement_stage", 0),
        (assign, "$attacker_reinforcement_stage", 0),
        (call_script, "script_place_player_banner_near_inventory"),
        (call_script, "script_combat_music_set_situation_with_culture"),
        (item_get_slot, ":var_0", "itm_no_item", 101),
        (assign, "$g_defender_reinforcement_limit", ":var_0"),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 0.000000, 5.000000, 
    [
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":var_0", reg0),
        (assign, ":var_1", 0),
        (try_for_agents, ":var_2"),
            (agent_is_human, ":var_2"),
            (agent_get_party_id, ":var_3", ":var_2"),
            (try_begin),
                (neg|eq, ":var_3", "p_main_party"),
                (neg|agent_is_ally, ":var_2"),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_4", ":var_0", ":var_1"),
        (try_begin),
            (neg|ge, ":var_4", 15),
            (ge, "$defender_reinforcement_stage", 2),
            (eq, "$defender_reinforcement_limit_increased", 0),
            (val_add, "$g_defender_reinforcement_limit", 1),
            (assign, "$defender_reinforcement_limit_increased", 1),
        (try_end),
        (neg|ge, "$defender_reinforcement_stage", "$g_defender_reinforcement_limit"),
        (store_mission_timer_a, ":var_5"),
        (ge, ":var_5", 10),
        (store_normalized_team_count, ":var_6", 0),
        (neg|ge, ":var_6", 10),
    ],
    [
        (add_reinforcements_to_entry, 0, 7),
        (assign, "$defender_reinforcement_limit_increased", 0),
        (val_add, "$defender_reinforcement_stage", 1),
    ]),

    (1.000000, 0.000000, 5.000000, 
    [
        (item_get_slot, ":var_0", "itm_no_item", 101),
        (neg|ge, "$attacker_reinforcement_stage", ":var_0"),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 1),
        (neg|ge, ":var_1", 10),
    ],
    [
        (add_reinforcements_to_entry, 3, 7),
        (val_add, "$attacker_reinforcement_stage", 1),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (assign, "$pin_player_fallen", 1),
        (display_message, "@You have fallen in battle!"),
        (set_show_messages, 0),
        (team_give_order, "$fplayer_team_no", 9, 2),
        (try_begin),
            (eq, "$g_option_formations", 1),
            (eq, "$g_disciplined_faction", 1),
            (team_set_order_listener, "$fplayer_team_no", 9, -1),
            (call_script, "script_player_order_formations", 2),
        (try_end),
        (team_give_order, "$fplayer_team_no", 9, 13),
        (team_give_order, "$fplayer_team_no", 9, 10),
        (set_show_messages, 1),
        (display_message, "@Your troops are charging!"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
    ],
    [
        (try_begin),
            (this_or_next|eq, "$g_option_formations", 0),
            (eq, "$g_disciplined_faction", 0),
            (call_script, "script_select_battle_tactic"),
            (call_script, "script_battle_tactic_init"),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_apply_effect_of_other_people_on_courage_scores"),
    ],
    [
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_routing", 0),
        (try_for_agents, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (store_mission_timer_a, ":var_1"),
            (ge, ":var_1", 3),
            (call_script, "script_decide_run_away_or_not", ":var_0", ":var_1"),
        (try_end),
    ],
    [
    ]),

    (5.000000, 0.000000, 0.000000, 
    [
        (this_or_next|eq, "$g_option_formations", 0),
        (eq, "$g_disciplined_faction", 0),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 3),
        (call_script, "script_battle_tactic_apply"),
    ],
    [
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_set_disciplined_faction"),
        (try_begin),
            (eq, "$g_option_formations", 1),
            (assign, "$gk_order", 0),
            (assign, "$gk_order_hold_over_there", 0),
            (assign, "$autorotate_at_player", 1),
            (assign, "$infantry_formation_type", 1),
            (assign, "$archer_formation_type", 1),
            (assign, "$cavalry_formation_type", 4),
            (assign, "$infantry_space", 2),
            (assign, "$archer_space", 2),
            (assign, "$cavalry_space", 0),
            (assign, "$fclock", 1),
            (assign, "$yield", 0),
        (try_end),
    ]),

    (0.100000, 0.000000, ti_once, 
    [
        (eq, "$g_option_formations", 1),
    ],
    [
        (assign, "$yield", 0),
        (call_script, "script_get_yield"),
        (val_div, "$yield", 4),
        (val_add, "$yield", 25),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
        (this_or_next|eq, "$g_option_formations", 0),
        (eq, "$g_disciplined_faction", 0),
    ],
    [
        (get_player_agent_no, "$fplayer_agent_no"),
        (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (set_show_messages, 0),
        (team_give_order, "$fplayer_team_no", 9, 0),
        (position_move_x, pos1, 1500),
        (position_move_y, pos1, 500),
        (team_set_order_position, "$fplayer_team_no", 2, pos1),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (position_move_x, pos1, -1500),
        (position_move_y, pos1, 500),
        (team_set_order_position, "$fplayer_team_no", 0, pos1),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (position_move_y, pos1, 2000),
        (team_set_order_position, "$fplayer_team_no", 1, pos1),
        (set_show_messages, 1),
    ]),

    (0.000000, 0.400000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (assign, ":var_0", 0),
            (assign, ":var_1", 0),
            (assign, ":var_2", 0),
            (assign, ":var_3", 0),
            (assign, "$team0_size", 0),
            (assign, "$team1_size", 0),
            (assign, "$team2_size", 0),
            (assign, "$team3_size", 0),
            (try_for_agents, ":var_4"),
                (agent_is_human, ":var_4"),
                (agent_get_team, ":var_5", ":var_4"),
                (agent_get_troop_id, ":var_6", ":var_4"),
                (store_troop_faction, ":var_7", ":var_6"),
                (try_begin),
                    (eq, ":var_5", 0),
                    (val_add, ":var_0", ":var_7"),
                    (val_add, "$team0_size", 1),
                (else_try),
                    (eq, ":var_5", 1),
                    (val_add, ":var_1", ":var_7"),
                    (val_add, "$team1_size", 1),
                (else_try),
                    (eq, ":var_5", 2),
                    (val_add, ":var_2", ":var_7"),
                    (val_add, "$team2_size", 1),
                (else_try),
                    (eq, ":var_5", 3),
                    (val_add, ":var_3", ":var_7"),
                    (val_add, "$team3_size", 1),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team0_size", 0),
                (team_get_leader, ":var_8", 0),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team0_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team0_faction", ":var_0", 10),
                    (val_div, "$team0_faction", "$team0_size"),
                    (val_add, "$team0_faction", 5),
                    (val_div, "$team0_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team1_size", 0),
                (team_get_leader, ":var_8", 1),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team1_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team1_faction", ":var_1", 10),
                    (val_div, "$team1_faction", "$team1_size"),
                    (val_add, "$team1_faction", 5),
                    (val_div, "$team1_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team2_size", 0),
                (team_get_leader, ":var_8", 2),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team2_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team2_faction", ":var_2", 10),
                    (val_div, "$team2_faction", "$team2_size"),
                    (val_add, "$team2_faction", 5),
                    (val_div, "$team2_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team3_size", 0),
                (team_get_leader, ":var_8", 3),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team3_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team3_faction", ":var_3", 10),
                    (val_div, "$team3_faction", "$team3_size"),
                    (val_add, "$team3_faction", 5),
                    (val_div, "$team3_faction", 10),
                (try_end),
            (try_end),
            (display_message, "@Forming ranks."),
            (call_script, "script_get_default_formation", "$fplayer_team_no"),
            (assign, "$infantry_formation_type", reg0),
            (call_script, "script_player_attempt_formation", 0, "$infantry_formation_type"),
            (call_script, "script_player_attempt_formation", 2, 4),
            (call_script, "script_player_attempt_formation", 1, 1),
            (set_show_messages, 0),
            (try_for_range, reg0, 3, 9),
                (team_give_order, "$fplayer_team_no", reg0, 0),
            (try_end),
            (try_for_range, reg0, 0, "$infantry_space"),
                (team_give_order, "$fplayer_team_no", 0, 8),
            (try_end),
            (try_for_range, reg0, 0, "$archer_space"),
                (team_give_order, "$fplayer_team_no", 1, 8),
            (try_end),
            (try_for_range, reg0, 0, "$cavalry_space"),
                (team_give_order, "$fplayer_team_no", 2, 8),
            (try_end),
            (set_show_messages, 1),
        (try_end),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_j),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_ranks", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 2),
        (call_script, "script_player_attempt_formation", 1, 2),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_k),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_shield", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 3),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_l),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_wedge", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 4),
        (call_script, "script_player_attempt_formation", 2, 4),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_semicolon),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_square", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 5),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_u),
    ],
    [
        (call_script, "script_player_order_formations", 2),
    ]),

    (0.000000, 0.300000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_1),
    ],
    [
        (eq, "$gk_order", 23),
        (game_key_is_down, gk_order_1),
        (assign, "$gk_order_hold_over_there", 1),
        (assign, "$gk_order", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_1),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 23),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_hold", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 0),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 24),
                (try_begin),
                    (store_random_in_range, ":var_2", 1, 101),
                    (neg|gt, ":var_2", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_advance", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 5),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_2),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 24),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_follow", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 1),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 24),
                (try_begin),
                    (store_random_in_range, ":var_2", 1, 101),
                    (neg|gt, ":var_2", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_fallback", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 6),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_3),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 25),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_charge", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 2),
            (else_try),
                (eq, "$gk_order", 24),
                (call_script, "script_player_order_formations", 8),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_4),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 23),
            (call_script, "script_player_order_formations", 11),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 24),
            (call_script, "script_player_order_formations", 7),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 25),
            (assign, "$gk_order", 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_5),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 23),
            (try_begin),
                (store_random_in_range, ":var_0", 1, 101),
                (neg|gt, ":var_0", "$yield"),
                (get_player_agent_no, ":var_1"),
                (agent_get_position, pos19, ":var_1"),
                (play_sound_at_position, "snd_th3_order_retreat", pos19),
            (try_end),
            (call_script, "script_player_order_formations", 14),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 24),
            (assign, "$gk_order", 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_6),
    ],
    [
        (eq, "$gk_order", 24),
        (try_begin),
            (class_is_listening_order, "$fplayer_team_no", 2),
            (call_script, "script_formation_end", "$fplayer_team_no", 2),
        (try_end),
        (call_script, "script_player_order_formations", 4),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_1),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (play_sound, "snd_th3_address_infantry"),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_2),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_archers", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_3),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_cavalry", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_0),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_everyone", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (this_or_next|key_clicked, key_1),
        (this_or_next|key_clicked, key_2),
        (this_or_next|key_clicked, key_3),
        (this_or_next|key_clicked, key_4),
        (this_or_next|key_clicked, key_5),
        (this_or_next|key_clicked, key_6),
        (this_or_next|key_clicked, key_7),
        (this_or_next|key_clicked, key_8),
        (this_or_next|key_clicked, key_9),
        (this_or_next|key_clicked, key_0),
        (key_clicked, key_escape),
    ],
    [
        (assign, "$gk_order", 0),
    ]),

    (0.500000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$gk_order_hold_over_there", 1),
        (neg|game_key_is_down, gk_order_1),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (play_sound, "snd_th3_order_hold"),
        (try_end),
        (call_script, "script_team_get_average_position_of_enemies_augmented", 60, "$fplayer_team_no", 9),
        (assign, ":var_1", 0),
        (try_for_range, reg0, 0, 9),
            (class_is_listening_order, "$fplayer_team_no", reg0),
            (val_add, ":var_1", 1),
        (try_end),
        (agent_get_position, pos22, "$fplayer_agent_no"),
        (try_begin),
            (neg|eq, "$infantry_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 0),
            (team_get_order_position, pos2, "$fplayer_team_no", 0),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 0, "$infantry_space", "$infantry_formation_type"),
                (try_end),
            (else_try),
                (assign, ":var_2", 0),
                (try_for_agents, reg0),
                    (call_script, "script_cf_valid_formation_member", "$fplayer_team_no", 0, "$fplayer_agent_no", reg0),
                    (val_add, ":var_2", 1),
                (try_end),
                (call_script, "script_get_centering_amount", "$infantry_formation_type", ":var_2", "$infantry_space"),
                (position_move_x, pos2, reg0),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 0, 1),
                (call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
            (try_end),
            (assign, "$infantry_formation_move_order", 0),
        (try_end),
        (try_begin),
            (neg|eq, "$cavalry_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 2),
            (team_get_order_position, pos2, "$fplayer_team_no", 2),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 2, "$cavalry_space", "$cavalry_formation_type"),
                (try_end),
            (else_try),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 2, 1),
                (call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
            (try_end),
            (assign, "$cavalry_formation_move_order", 0),
        (try_end),
        (try_begin),
            (neg|eq, "$archer_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 1),
            (team_get_order_position, pos2, "$fplayer_team_no", 1),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 1, "$archer_space", "$archer_formation_type"),
                (try_end),
            (else_try),
                (assign, ":var_2", 0),
                (try_for_agents, reg0),
                    (call_script, "script_cf_valid_formation_member", "$fplayer_team_no", 1, "$fplayer_agent_no", reg0),
                    (val_add, ":var_2", 1),
                (try_end),
                (call_script, "script_get_centering_amount", 1, ":var_2", "$archer_space"),
                (val_mul, reg0, -1),
                (position_move_x, pos2, reg0),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 1, 1),
                (call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space", "$archer_formation_type"),
            (try_end),
            (assign, "$archer_formation_move_order", 0),
        (try_end),
        (agent_set_position, "$fplayer_agent_no", pos22),
        (assign, "$gk_order_hold_over_there", 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (neg|key_is_down, key_j),
        (neg|key_is_down, key_k),
        (neg|key_is_down, key_l),
        (neg|key_is_down, key_semicolon),
        (neg|key_is_down, key_u),
        (neg|game_key_is_down, gk_order_1),
        (neg|game_key_is_down, gk_order_2),
        (neg|game_key_is_down, gk_order_3),
        (neg|game_key_is_down, gk_order_4),
        (neg|game_key_is_down, gk_order_5),
        (neg|game_key_is_down, gk_order_6),
    ],
    [
        (set_fixed_point_multiplier, 100),
        (store_mod, ":var_0", "$fclock", 5),
        (call_script, "script_team_get_average_position_of_enemies_augmented", 60, "$fplayer_team_no", 9),
        (try_begin),
            (eq, reg0, 0),
            (neg|eq, "$g_encountered_party", -1),
            (call_script, "script_formation_end", "$fplayer_team_no", 9),
        (else_try),
            (assign, "$autorotate_at_player", 0),
            (try_begin),
                (neg|eq, "$infantry_formation_type", 0),
                (try_begin),
                    (eq, "$infantry_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 0, "$infantry_space", "$infantry_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 0),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 0),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 0, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, "$cavalry_formation_type", 0),
                (try_begin),
                    (eq, "$cavalry_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 2, "$cavalry_space", "$cavalry_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 2),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 2),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 2, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, "$archer_formation_type", 0),
                (try_begin),
                    (eq, "$archer_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 1, "$archer_space", "$archer_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 1),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 1),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 1, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space", "$archer_formation_type"),
                (try_end),
            (try_end),
            (assign, "$autorotate_at_player", 1),
        (try_end),
        (val_add, "$fclock", 1),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (assign, "$cur_casualties", 0),
            (assign, "$prev_casualties", 0),
            (assign, "$prev_casualties2", 0),
            (assign, "$ranged_clock", 1),
            (assign, "$battle_phase", 1),
            (assign, "$clock_reset", 0),
            (assign, "$charge_activated", 0),
            (assign, "$charge_ongoing", 0),
            (assign, "$inf_charge_activated", 0),
            (assign, "$inf_charge_ongoing", 0),
            (assign, "$arc_charge_activated", 0),
            (assign, "$att_reinforcements_arrived", 0),
            (assign, "$def_reinforcements_arrived", 0),
            (assign, "$att_reinforcements_needed", 0),
            (assign, "$def_reinforcements_needed", 0),
            (assign, "$disengage", 0),
            (assign, "$patrol_mode", 0),
            (store_random_in_range, "$rand0", -1000, 1000),
            (store_random_in_range, "$rand2", 800, 1501),
            (store_random_in_range, "$rand1", 0, 501),
            (store_random_in_range, "$rand3", 2000, 3001),
            (store_random_in_range, "$rand4", 1000, 3001),
            (store_random_in_range, "$rand5", -1000, 0),
            (store_random_in_range, "$rand6", 4000, 5001),
            (store_random_in_range, "$rand7", 49, 56),
            (store_random_in_range, "$rand8", -100, 101),
            (assign, "$team0_default_formation", 1),
            (assign, "$team1_default_formation", 1),
            (assign, "$team2_default_formation", 1),
            (assign, "$team3_default_formation", 1),
            (init_position, pos56),
            (init_position, pos57),
            (init_position, pos58),
            (init_position, pos59),
            (assign, "$team0_reinforcement_stage", 0),
            (assign, "$team1_reinforcement_stage", 0),
            (init_position, pos17),
            (init_position, pos18),
        (try_end),
    ]),

    (0.000000, 0.500000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (eq, "$g_disciplined_faction", 1),
            (try_for_agents, ":var_0"),
                (agent_set_slot, ":var_0", slot_agent_is_running_away, 0),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (call_script, "script_store_battlegroup_data"),
            (call_script, "script_battlegroup_get_position", 12, 0, 9),
            (call_script, "script_battlegroup_get_position", 13, 1, 9),
            (call_script, "script_battlegroup_get_position", 14, 2, 9),
            (call_script, "script_battlegroup_get_position", 16, 3, 9),
            (call_script, "script_field_tactics", 1),
        (try_end),
    ]),

    (60.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$g_disciplined_faction", 1),
    ],
    [
        (store_random_in_range, "$rand0", -1000, 1000),
        (store_random_in_range, "$rand2", 800, 1501),
        (store_random_in_range, "$rand1", -1000, 1000),
        (store_random_in_range, "$rand3", 2000, 3001),
        (store_random_in_range, "$rand4", 1000, 3001),
        (store_random_in_range, "$rand5", -1000, 0),
        (store_random_in_range, "$rand6", 4000, 5001),
        (store_random_in_range, "$rand7", 45, 56),
        (store_random_in_range, "$rand8", -100, 101),
    ]),

    (1.000000, 0.900000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$g_disciplined_faction", 1),
    ],
    [
        (try_begin),
            (assign, "$prev_casualties2", "$cur_casualties"),
            (call_script, "script_cf_count_casualties"),
            (assign, "$cur_casualties", reg0),
            (assign, "$battle_phase", 3),
        (try_end),
        (set_fixed_point_multiplier, 100),
        (call_script, "script_store_battlegroup_data"),
        (try_begin),
            (eq, "$battle_phase", 3),
            (eq, "$clock_reset", 0),
            (call_script, "script_field_tactics", 1),
            (assign, "$ranged_clock", 0),
            (assign, "$clock_reset", 1),
        (else_try),
            (ge, "$battle_phase", 2),
            (store_mod, reg0, "$ranged_clock", 5),
            (eq, reg0, 0),
            (call_script, "script_field_tactics", 1),
            (assign, "$team0_reinforcement_stage", "$defender_reinforcement_stage"),
            (assign, "$team1_reinforcement_stage", "$attacker_reinforcement_stage"),
        (else_try),
            (call_script, "script_field_tactics", 0),
        (try_end),
        (try_begin),
            (eq, "$battle_phase", 1),
            (assign, ":var_0", 0),
            (try_for_range, ":var_1", 0, 4),
                (neg|eq, ":var_1", "$fplayer_team_no"),
                (call_script, "script_battlegroup_get_size", ":var_1", 9),
                (gt, reg0, 0),
                (call_script, "script_battlegroup_get_position", 1, ":var_1", 1),
                (team_get_order_position, pos0, ":var_1", 1),
                (get_distance_between_positions, reg0, pos0, pos1),
                (gt, reg0, 500),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 0),
            (assign, "$battle_phase", 2),
        (try_end),
        (val_add, "$ranged_clock", 1),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_horse_archer_ai", 1),
    ],
    [
        (set_fixed_point_multiplier, 100),
        (try_for_agents, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (try_begin),
                (agent_is_alive, ":var_0"),
                (agent_is_human, ":var_0"),
                (agent_is_non_player, ":var_0"),
                (agent_is_active, ":var_0"),
                (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
                (agent_get_horse, ":var_2", ":var_0"),
                (gt, ":var_2", 0),
                (agent_get_ammo, ":var_3", ":var_0"),
                (gt, ":var_3", 0),
                (store_skill_level, ":var_4", "skl_horse_archery", ":var_1"),
                (ge, ":var_4", 4),
                (agent_get_division, ":var_5", ":var_0"),
                (agent_get_team, ":var_6", ":var_0"),
                (team_get_hold_fire_order, ":var_7", ":var_6", ":var_5"),
                (neg|eq, ":var_7", 1),
                (team_get_weapon_usage_order, ":var_8", ":var_6", ":var_5"),
                (eq, ":var_8", 0),
                (team_get_movement_order, reg0, ":var_6", ":var_5"),
                (eq, reg0, 2),
                (assign, ":var_9", 0),
                (assign, ":var_10", 0),
                (try_for_range, ":var_11", 0, 4),
                    (agent_get_item_slot, ":var_12", ":var_0", ":var_11"),
                    (gt, ":var_12", -1),
                    (item_get_type, ":var_13", ":var_12"),
                    (try_begin),
                        (eq, ":var_13", 4),
                        (item_get_slot, ":var_14", ":var_12", 201),
                        (store_and, ":var_15", ":var_14", 2147483648),
                        (gt, ":var_15", 0),
                        (assign, ":var_10", 1),
                    (try_end),
                    (eq, ":var_13", 8),
                    (assign, ":var_9", 1),
                (try_end),
                (eq, ":var_9", 1),
                (eq, ":var_10", 0),
                (agent_get_wielded_item, ":var_16", ":var_0", 0),
                (gt, ":var_16", -1),
                (item_get_type, ":var_17", ":var_16"),
                (eq, ":var_17", 8),
                (call_script, "script_agent_get_closest_enemy", ":var_0", 200),
                (assign, ":var_18", reg1),
                (assign, ":var_19", reg4),
                (gt, ":var_19", -1),
                (neg|ge, ":var_18", 12000),
                (agent_set_accuracy_modifier, ":var_0", 120),
                (call_script, "script_horse_archer_agent_skirmish", ":var_0", ":var_19", ":var_18"),
                (try_begin),
                    (neg|ge, ":var_18", 5000),
                    (store_random_in_range, ":var_20", 0, 10),
                    (neg|gt, ":var_20", 2),
                    (agent_get_attack_action, ":var_21", ":var_0"),
                    (eq, ":var_21", 0),
                    (agent_get_combat_state, ":var_22", ":var_0"),
                    (is_between, ":var_22", 0, 2),
                    (agent_get_wielded_item, ":var_23", ":var_0", 0),
                    (gt, ":var_23", 0),
                    (item_get_type, ":var_17", ":var_23"),
                    (this_or_next|eq, ":var_17", 8),
                    (eq, ":var_17", 9),
                    (agent_set_attack_action, ":var_0", 0, 0),
                (try_end),
                (agent_force_rethink, ":var_0"),
            (else_try),
                (agent_slot_ge, ":var_0", 251, 1),
                (agent_set_slot, ":var_0", 251, 0),
                (agent_clear_scripted_mode, ":var_0"),
                (agent_set_accuracy_modifier, ":var_0", 100),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_v),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (set_show_messages, 0),
        (try_for_range, ":var_2", 0, 9),
            (class_is_listening_order, ":var_1", ":var_2"),
            (team_give_order, ":var_1", ":var_2", 0),
        (try_end),
        (get_player_agent_no, ":var_3"),
        (try_for_agents, ":var_4"),
            (agent_is_alive, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_get_team, ":var_5", ":var_4"),
            (eq, ":var_5", ":var_1"),
            (agent_get_division, ":var_2", ":var_4"),
            (class_is_listening_order, ":var_1", ":var_2"),
            (agent_get_horse, ":var_6", ":var_4"),
            (neg|gt, ":var_6", 0),
            (neg|eq, ":var_4", ":var_3"),
            (agent_set_is_alarmed, ":var_4", 0),
            (agent_get_slot, ":var_7", ":var_4", 250),
            (ge, ":var_7", 10),
            (try_begin),
                (agent_get_animation, ":var_8", ":var_4"),
                (assign, ":var_9", "anim_spearwall_hold"),
                (neg|eq, ":var_8", ":var_9"),
                (agent_set_animation, ":var_4", ":var_9"),
                (agent_get_position, pos1, ":var_4"),
                (agent_set_scripted_destination, ":var_4", pos1),
                (set_fixed_point_multiplier, 100),
                (agent_get_look_position, pos1, ":var_4"),
                (position_get_x, ":var_10", pos1),
                (position_get_y, ":var_11", pos1),
                (agent_set_slot, ":var_4", slot_agent_target_x_pos, ":var_10"),
                (agent_set_slot, ":var_4", slot_agent_target_y_pos, ":var_11"),
            (try_end),
        (try_end),
        (set_show_messages, 1),
    ]),

    (0.100000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (agent_get_horse, ":var_2", ":var_0"),
        (try_for_agents, ":var_3"),
            (agent_is_alive, ":var_3"),
            (agent_is_human, ":var_3"),
            (agent_slot_eq, ":var_3", slot_agent_is_running_away, 0),
            (agent_get_horse, ":var_4", ":var_3"),
            (neg|gt, ":var_4", 0),
            (agent_get_slot, ":var_5", ":var_3", 250),
            (agent_get_simple_behavior, ":var_6", ":var_3"),
            (agent_get_team, ":var_7", ":var_3"),
            (agent_get_class, ":var_8", ":var_3"),
            (team_get_movement_order, ":var_9", ":var_7", ":var_8"),
            (assign, ":var_10", 0),
            (agent_get_animation, ":var_11", ":var_3"),
            (try_begin),
                (neg|eq, ":var_7", ":var_1"),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (this_or_next|eq, ":var_9", 0),
                (eq, ":var_9", 11),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
                (neg|eq, ":var_3", ":var_0"),
                (assign, ":var_12", "anim_spearwall_hold"),
                (eq, ":var_11", ":var_12"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
                (assign, ":var_10", 0),
            (try_end),
            (try_begin),
                (eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (assign, ":var_10", 1),
            (try_end),
            (eq, ":var_10", 1),
            (agent_get_wielded_item, ":var_13", ":var_3", 0),
            (try_begin),
                (neg|ge, ":var_13", 0),
                (agent_get_wielded_item, ":var_13", ":var_3", 1),
            (try_end),
            (ge, ":var_13", 0),
            (item_get_type, ":var_14", ":var_13"),
            (eq, ":var_14", 4),
            (item_get_slot, ":var_15", ":var_13", 17),
            (try_begin),
                (eq, ":var_15", 0),
                (assign, ":var_15", 145),
            (try_end),
            (val_add, ":var_15", 10),
            (try_begin),
                (agent_get_speed, pos0, ":var_3"),
                (position_get_y, ":var_16", pos0),
                (position_get_x, ":var_17", pos0),
                (val_max, ":var_16", ":var_17"),
                (eq, ":var_16", 0),
                (agent_get_troop_id, ":var_18", ":var_3"),
                (store_proficiency_level, ":var_19", ":var_18", wpt_polearm),
                (store_character_level, ":var_20", ":var_18"),
                (ge, ":var_20", 12),
                (ge, ":var_19", 120),
                (item_get_slot, ":var_21", ":var_13", 200),
                (store_and, ":var_22", ":var_21", 256),
                (gt, ":var_22", 0),
                (assign, ":var_10", 1),
                (agent_get_wielded_item, ":var_23", ":var_3", 1),
                (try_begin),
                    (gt, ":var_23", 0),
                    (item_get_type, ":var_24", ":var_23"),
                    (eq, ":var_24", 7),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_10", 1),
                (try_begin),
                    (neg|ge, ":var_5", 50),
                    (val_add, ":var_5", 1),
                    (agent_set_slot, ":var_3", 250, ":var_5"),
                (try_end),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
                (assign, ":var_5", 0),
            (try_end),
            (this_or_next|eq, ":var_3", ":var_0"),
            (ge, ":var_5", 20),
            (try_begin),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_get_position, pos1, ":var_3"),
                (agent_set_scripted_destination, ":var_3", pos1),
                (agent_set_is_alarmed, ":var_3", 0),
                (agent_get_slot, ":var_25", ":var_3", slot_agent_target_x_pos),
                (agent_get_slot, ":var_26", ":var_3", slot_agent_target_y_pos),
                (init_position, pos2),
                (position_set_x, pos2, ":var_25"),
                (position_set_y, pos2, ":var_26"),
                (agent_set_look_target_position, ":var_3", pos2),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (assign, ":var_27", -1),
            (assign, ":var_28", -1),
            (agent_get_position, pos1, ":var_3"),
            (try_for_agents, ":var_29"),
                (agent_is_alive, ":var_29"),
                (neg|agent_is_human, ":var_29"),
                (agent_get_rider, ":var_30", ":var_29"),
                (ge, ":var_30", 0),
                (agent_get_team, ":var_31", ":var_30"),
                (teams_are_enemies, ":var_7", ":var_31"),
                (agent_get_position, pos2, ":var_29"),
                (get_distance_between_positions, ":var_32", pos1, pos2),
                (neg|ge, ":var_32", ":var_15"),
                (neg|position_is_behind_position, 2, 1),
                (agent_get_speed, pos4, ":var_29"),
                (position_get_x, ":var_33", pos4),
                (position_get_y, ":var_34", pos4),
                (this_or_next|gt, ":var_33", 350),
                (gt, ":var_34", 350),
                (get_angle_between_positions, ":var_35", pos1, pos2),
                (val_abs, ":var_35"),
                (convert_from_fixed_point, ":var_35"),
                (is_between, ":var_35", 150, 181),
                (assign, ":var_27", ":var_29"),
                (assign, ":var_28", ":var_30"),
            (try_end),
            (try_begin),
                (eq, ":var_27", -1),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (store_sub, ":var_32", ":var_15", 20),
                (call_script, "script_agent_get_closest_enemy", ":var_3", ":var_32"),
                (ge, reg0, 1),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_set_slot, ":var_3", 250, 0),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
            (try_end),
            (gt, ":var_27", -1),
            (val_mul, ":var_33", ":var_33"),
            (val_mul, ":var_34", ":var_34"),
            (store_add, ":var_36", ":var_33", ":var_34"),
            (store_sqrt, ":var_36", ":var_36"),
            (val_div, ":var_36", 100),
            (store_mul, ":var_37", ":var_36", 4),
            (try_begin),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
            (try_end),
            (agent_clear_scripted_mode, ":var_3"),
            (agent_set_slot, ":var_3", 250, 0),
            (agent_play_sound, ":var_27", "snd_metal_hit_high_armor_high_damage"),
            (store_agent_hit_points, ":var_38", ":var_27", 1),
            (store_sub, ":var_39", ":var_38", ":var_37"),
            (val_max, ":var_39", 0),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27", ":var_37"),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27"),
            (store_agent_hit_points, ":var_39", ":var_27", 1),
            (store_agent_hit_points, ":var_40", ":var_28", 1),
            (try_begin),
                (gt, ":var_39", 0),
                (agent_set_animation, ":var_27", "anim_horse_rear"),
            (else_try),
                (neg|gt, ":var_39", 0),
                (agent_deliver_damage_to_agent, ":var_27", ":var_28"),
            (try_end),
            (store_agent_hit_points, ":var_41", ":var_28", 1),
            (try_begin),
                (eq, ":var_27", ":var_2"),
                (val_sub, ":var_38", ":var_39"),
                (assign, reg1, ":var_38"),
                (display_message, "@Your horse received {reg1} damage from a braced spear!", 0xFF4040),
                (try_begin),
                    (val_sub, ":var_40", ":var_41"),
                    (gt, ":var_40", 0),
                    (assign, reg2, ":var_40"),
                    (display_message, "@You received {reg2} damage from a braced spear!", 0xFF4040),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),
        (this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),
        (game_key_clicked, gk_sheath_weapon),
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_animation, ":var_1", ":var_0"),
        (eq, ":var_1", "anim_spearwall_hold"),
        (agent_set_animation, ":var_0", "anim_spearwall_hold_recoil"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_b),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (try_begin),
            (neg|ge, ":var_1", 0),
            (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (try_end),
        (ge, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 4),
        (item_get_slot, ":var_3", ":var_1", 200),
        (store_and, ":var_4", ":var_3", 256),
        (gt, ":var_4", 0),
        (assign, ":var_5", 1),
        (agent_get_wielded_item, ":var_6", ":var_0", 1),
        (try_begin),
            (gt, ":var_6", 0),
            (item_get_type, ":var_7", ":var_6"),
            (eq, ":var_7", 7),
            (assign, ":var_5", 0),
        (try_end),
        (eq, ":var_5", 1),
        (agent_get_horse, ":var_8", ":var_0"),
        (neg|gt, ":var_8", 0),
        (agent_get_animation, ":var_9", ":var_0"),
        (neg|eq, ":var_9", "anim_spearwall_hold"),
        (neg|eq, ":var_9", "anim_spearwall_hold_recoil"),
        (str_store_item_name, s1, ":var_1"),
        (display_message, "@Bracing {s1} for charge.", 0x6495ED),
        (agent_set_animation, ":var_0", "anim_spearwall_hold"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),

    (2.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, reg0),
        (gt, reg0, 1),
    ],
    [
        (set_show_messages, 0),
        (try_for_range, ":var_0", 0, 4),
            (team_give_order, ":var_0", 2, 3),
        (try_end),
        (set_show_messages, 1),
    ]),


],),

(
"village_attack_bandits", 65538, 8, 
"You_lead_your_men_to_battle.",
[(3, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(1, mtef_team_0|mtef_use_exact_number, 0, 16, 7, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$pop_camera_on", 0),
        (assign, "$pop_camera_mouse_center_x", 500),
        (assign, "$pop_camera_mouse_center_y", 375),
        (assign, "$pop_camera_mouse_x", "$pop_camera_mouse_center_x"),
        (assign, "$pop_camera_mouse_y", "$pop_camera_mouse_center_y"),
        (assign, "$pop_camera_mouse_counter", 0),
    ]),

    (0.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (eq, "$pop_camera_on", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (position_get_x, ":var_1", pos1),
        (position_get_y, ":var_2", pos1),
        (init_position, pos23),
        (position_set_x, pos23, ":var_1"),
        (position_set_y, pos23, ":var_2"),
        (position_set_z_to_ground_level, pos23),
        (position_move_z, pos23, 250),
        (mission_cam_set_mode, 1, 0, 0),
        (mission_cam_set_position, pos23),
        (assign, "$pop_camera_rotx", 0),
        (assign, "$pop_camera_on", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_is_down, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_is_down, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_is_down, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (game_key_is_down, gk_move_right),
    ],
    [
        (mission_cam_get_position, pos23),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_forward),
            (game_key_is_down, gk_move_forward),
            (assign, ":var_1", 10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_backward),
            (game_key_is_down, gk_move_backward),
            (assign, ":var_1", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_left),
            (game_key_is_down, gk_move_left),
            (assign, ":var_0", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_right),
            (game_key_is_down, gk_move_right),
            (assign, ":var_0", 10),
        (try_end),
        (position_move_x, pos23, ":var_0"),
        (position_move_y, pos23, ":var_1"),
        (mission_cam_set_position, pos23),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (neg|is_presentation_active, "prsnt_battle"),
        (mouse_get_position, pos1),
        (set_fixed_point_multiplier, 1000),
        (position_get_x, reg1, pos1),
        (position_get_y, reg2, pos1),
        (this_or_next|neg|eq, reg1, "$pop_camera_mouse_center_x"),
        (neg|eq, reg2, "$pop_camera_mouse_center_y"),
    ],
    [
        (assign, ":var_0", 1),
        (try_begin),
            (eq, reg1, "$pop_camera_mouse_x"),
            (eq, reg2, "$pop_camera_mouse_y"),
            (val_add, "$pop_camera_mouse_counter", 1),
            (try_begin),
                (gt, "$pop_camera_mouse_counter", 30),
                (assign, "$pop_camera_mouse_center_x", reg1),
                (assign, "$pop_camera_mouse_center_y", reg2),
                (assign, "$pop_camera_mouse_counter", 0),
            (try_end),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
        (assign, "$pop_camera_mouse_counter", 0),
        (assign, "$pop_camera_mouse_x", reg1),
        (assign, "$pop_camera_mouse_y", reg2),
        (mission_cam_get_position, pos23),
        (store_sub, ":var_1", "$pop_camera_mouse_center_x", reg1),
        (store_sub, ":var_2", reg2, "$pop_camera_mouse_center_y"),
        (try_for_range, ":var_3", 0, 2),
            (try_begin),
                (eq, ":var_3", 1),
                (assign, ":var_1", ":var_2"),
            (try_end),
            (this_or_next|neg|ge, ":var_1", -2),
            (gt, ":var_1", 2),
            (assign, ":var_4", 1),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_4", -1),
            (try_end),
            (val_abs, ":var_1"),
            (val_sub, ":var_1", 2),
            (convert_to_fixed_point, ":var_1"),
            (store_sqrt, ":var_1", ":var_1"),
            (convert_from_fixed_point, ":var_1"),
            (val_clamp, ":var_1", 1, 10),
            (val_mul, ":var_1", ":var_4"),
            (try_begin),
                (eq, ":var_3", 0),
                (store_mul, ":var_5", "$pop_camera_rotx", -1),
                (position_rotate_x, pos23, ":var_5"),
                (position_rotate_z, pos23, ":var_1"),
                (position_rotate_x, pos23, "$pop_camera_rotx"),
            (else_try),
                (position_rotate_x, pos23, ":var_1"),
                (val_add, "$pop_camera_rotx", ":var_1"),
            (try_end),
        (try_end),
        (mission_cam_set_position, pos23),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (str_store_string, s5, "str_retreat"),
        (call_script, "script_simulate_retreat", 10, 20, 1),
        (assign, "$g_battle_result", -1),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (assign, "$defender_reinforcement_stage", 0),
        (assign, "$attacker_reinforcement_stage", 0),
        (try_begin),
            (eq, "$g_mt_mode", 2),
            (add_reinforcements_to_entry, 1, 6),
        (else_try),
            (add_reinforcements_to_entry, 1, 29),
        (try_end),
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_v),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (set_show_messages, 0),
        (try_for_range, ":var_2", 0, 9),
            (class_is_listening_order, ":var_1", ":var_2"),
            (team_give_order, ":var_1", ":var_2", 0),
        (try_end),
        (get_player_agent_no, ":var_3"),
        (try_for_agents, ":var_4"),
            (agent_is_alive, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_get_team, ":var_5", ":var_4"),
            (eq, ":var_5", ":var_1"),
            (agent_get_division, ":var_2", ":var_4"),
            (class_is_listening_order, ":var_1", ":var_2"),
            (agent_get_horse, ":var_6", ":var_4"),
            (neg|gt, ":var_6", 0),
            (neg|eq, ":var_4", ":var_3"),
            (agent_set_is_alarmed, ":var_4", 0),
            (agent_get_slot, ":var_7", ":var_4", 250),
            (ge, ":var_7", 10),
            (try_begin),
                (agent_get_animation, ":var_8", ":var_4"),
                (assign, ":var_9", "anim_spearwall_hold"),
                (neg|eq, ":var_8", ":var_9"),
                (agent_set_animation, ":var_4", ":var_9"),
                (agent_get_position, pos1, ":var_4"),
                (agent_set_scripted_destination, ":var_4", pos1),
                (set_fixed_point_multiplier, 100),
                (agent_get_look_position, pos1, ":var_4"),
                (position_get_x, ":var_10", pos1),
                (position_get_y, ":var_11", pos1),
                (agent_set_slot, ":var_4", slot_agent_target_x_pos, ":var_10"),
                (agent_set_slot, ":var_4", slot_agent_target_y_pos, ":var_11"),
            (try_end),
        (try_end),
        (set_show_messages, 1),
    ]),

    (0.100000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (agent_get_horse, ":var_2", ":var_0"),
        (try_for_agents, ":var_3"),
            (agent_is_alive, ":var_3"),
            (agent_is_human, ":var_3"),
            (agent_slot_eq, ":var_3", slot_agent_is_running_away, 0),
            (agent_get_horse, ":var_4", ":var_3"),
            (neg|gt, ":var_4", 0),
            (agent_get_slot, ":var_5", ":var_3", 250),
            (agent_get_simple_behavior, ":var_6", ":var_3"),
            (agent_get_team, ":var_7", ":var_3"),
            (agent_get_class, ":var_8", ":var_3"),
            (team_get_movement_order, ":var_9", ":var_7", ":var_8"),
            (assign, ":var_10", 0),
            (agent_get_animation, ":var_11", ":var_3"),
            (try_begin),
                (neg|eq, ":var_7", ":var_1"),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (this_or_next|eq, ":var_9", 0),
                (eq, ":var_9", 11),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
                (neg|eq, ":var_3", ":var_0"),
                (assign, ":var_12", "anim_spearwall_hold"),
                (eq, ":var_11", ":var_12"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
                (assign, ":var_10", 0),
            (try_end),
            (try_begin),
                (eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (assign, ":var_10", 1),
            (try_end),
            (eq, ":var_10", 1),
            (agent_get_wielded_item, ":var_13", ":var_3", 0),
            (try_begin),
                (neg|ge, ":var_13", 0),
                (agent_get_wielded_item, ":var_13", ":var_3", 1),
            (try_end),
            (ge, ":var_13", 0),
            (item_get_type, ":var_14", ":var_13"),
            (eq, ":var_14", 4),
            (item_get_slot, ":var_15", ":var_13", 17),
            (try_begin),
                (eq, ":var_15", 0),
                (assign, ":var_15", 145),
            (try_end),
            (val_add, ":var_15", 10),
            (try_begin),
                (agent_get_speed, pos0, ":var_3"),
                (position_get_y, ":var_16", pos0),
                (position_get_x, ":var_17", pos0),
                (val_max, ":var_16", ":var_17"),
                (eq, ":var_16", 0),
                (agent_get_troop_id, ":var_18", ":var_3"),
                (store_proficiency_level, ":var_19", ":var_18", wpt_polearm),
                (store_character_level, ":var_20", ":var_18"),
                (ge, ":var_20", 12),
                (ge, ":var_19", 120),
                (item_get_slot, ":var_21", ":var_13", 200),
                (store_and, ":var_22", ":var_21", 256),
                (gt, ":var_22", 0),
                (assign, ":var_10", 1),
                (agent_get_wielded_item, ":var_23", ":var_3", 1),
                (try_begin),
                    (gt, ":var_23", 0),
                    (item_get_type, ":var_24", ":var_23"),
                    (eq, ":var_24", 7),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_10", 1),
                (try_begin),
                    (neg|ge, ":var_5", 50),
                    (val_add, ":var_5", 1),
                    (agent_set_slot, ":var_3", 250, ":var_5"),
                (try_end),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
            (try_end),
            (this_or_next|eq, ":var_3", ":var_0"),
            (ge, ":var_5", 20),
            (try_begin),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_get_position, pos1, ":var_3"),
                (agent_set_scripted_destination, ":var_3", pos1),
                (agent_set_is_alarmed, ":var_3", 0),
                (agent_get_slot, ":var_25", ":var_3", slot_agent_target_x_pos),
                (agent_get_slot, ":var_26", ":var_3", slot_agent_target_y_pos),
                (init_position, pos2),
                (position_set_x, pos2, ":var_25"),
                (position_set_y, pos2, ":var_26"),
                (agent_set_look_target_position, ":var_3", pos2),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (assign, ":var_27", -1),
            (assign, ":var_28", -1),
            (agent_get_position, pos1, ":var_3"),
            (try_for_agents, ":var_29"),
                (agent_is_alive, ":var_29"),
                (neg|agent_is_human, ":var_29"),
                (agent_get_rider, ":var_30", ":var_29"),
                (ge, ":var_30", 0),
                (agent_get_team, ":var_31", ":var_30"),
                (teams_are_enemies, ":var_7", ":var_31"),
                (agent_get_position, pos2, ":var_29"),
                (get_distance_between_positions, ":var_32", pos1, pos2),
                (neg|ge, ":var_32", ":var_15"),
                (neg|position_is_behind_position, 2, 1),
                (agent_get_speed, pos4, ":var_29"),
                (position_get_x, ":var_33", pos4),
                (position_get_y, ":var_34", pos4),
                (this_or_next|gt, ":var_33", 350),
                (gt, ":var_34", 350),
                (get_angle_between_positions, ":var_35", pos1, pos2),
                (val_abs, ":var_35"),
                (convert_from_fixed_point, ":var_35"),
                (is_between, ":var_35", 150, 181),
                (assign, ":var_27", ":var_29"),
                (assign, ":var_28", ":var_30"),
            (try_end),
            (try_begin),
                (eq, ":var_27", -1),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (store_sub, ":var_32", ":var_15", 20),
                (call_script, "script_agent_get_closest_enemy", ":var_3", ":var_32"),
                (ge, reg0, 1),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_set_slot, ":var_3", 250, 0),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
            (try_end),
            (gt, ":var_27", -1),
            (val_mul, ":var_33", ":var_33"),
            (val_mul, ":var_34", ":var_34"),
            (store_add, ":var_36", ":var_33", ":var_34"),
            (store_sqrt, ":var_36", ":var_36"),
            (val_div, ":var_36", 100),
            (store_mul, ":var_37", ":var_36", 4),
            (try_begin),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
            (try_end),
            (agent_clear_scripted_mode, ":var_3"),
            (agent_set_slot, ":var_3", 250, 0),
            (agent_play_sound, ":var_27", "snd_metal_hit_high_armor_high_damage"),
            (store_agent_hit_points, ":var_38", ":var_27", 1),
            (store_sub, ":var_39", ":var_38", ":var_37"),
            (val_max, ":var_39", 0),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27", ":var_37"),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27"),
            (store_agent_hit_points, ":var_39", ":var_27", 1),
            (store_agent_hit_points, ":var_40", ":var_28", 1),
            (try_begin),
                (gt, ":var_39", 0),
                (agent_set_animation, ":var_27", "anim_horse_rear"),
            (else_try),
                (neg|gt, ":var_39", 0),
                (agent_deliver_damage_to_agent, ":var_27", ":var_28"),
            (try_end),
            (store_agent_hit_points, ":var_41", ":var_28", 1),
            (try_begin),
                (eq, ":var_27", ":var_2"),
                (val_sub, ":var_38", ":var_39"),
                (assign, reg1, ":var_38"),
                (display_message, "@Your horse received {reg1} damage from a braced spear!", 0xFF4040),
                (try_begin),
                    (val_sub, ":var_40", ":var_41"),
                    (gt, ":var_40", 0),
                    (assign, reg2, ":var_40"),
                    (display_message, "@You received {reg2} damage from a braced spear!", 0xFF4040),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),
        (this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),
        (game_key_clicked, gk_sheath_weapon),
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_animation, ":var_1", ":var_0"),
        (eq, ":var_1", "anim_spearwall_hold"),
        (agent_set_animation, ":var_0", "anim_spearwall_hold_recoil"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_b),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (try_begin),
            (neg|ge, ":var_1", 0),
            (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (try_end),
        (ge, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 4),
        (item_get_slot, ":var_3", ":var_1", 200),
        (store_and, ":var_4", ":var_3", 256),
        (gt, ":var_4", 0),
        (assign, ":var_5", 1),
        (agent_get_wielded_item, ":var_6", ":var_0", 1),
        (try_begin),
            (gt, ":var_6", 0),
            (item_get_type, ":var_7", ":var_6"),
            (eq, ":var_7", 7),
            (assign, ":var_5", 0),
        (try_end),
        (eq, ":var_5", 1),
        (agent_get_horse, ":var_8", ":var_0"),
        (neg|gt, ":var_8", 0),
        (agent_get_animation, ":var_9", ":var_0"),
        (neg|eq, ":var_9", "anim_spearwall_hold"),
        (neg|eq, ":var_9", "anim_spearwall_hold_recoil"),
        (str_store_item_name, s1, ":var_1"),
        (display_message, "@Bracing {s1} for charge.", 0x6495ED),
        (agent_set_animation, ":var_0", "anim_spearwall_hold"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"village_raid", 65538, 8, 
"You_lead_your_men_to_battle.",
[(3, mtef_defenders|mtef_team_0, af_override_horse, 16, 12, []),
(3, mtef_defenders|mtef_team_0, af_override_horse, 16, 0, []),
(1, mtef_attackers|mtef_team_1, af_override_horse, 16, 12, []),
(1, mtef_attackers|mtef_team_1, af_override_horse, 16, 0, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$pop_camera_on", 0),
        (assign, "$pop_camera_mouse_center_x", 500),
        (assign, "$pop_camera_mouse_center_y", 375),
        (assign, "$pop_camera_mouse_x", "$pop_camera_mouse_center_x"),
        (assign, "$pop_camera_mouse_y", "$pop_camera_mouse_center_y"),
        (assign, "$pop_camera_mouse_counter", 0),
    ]),

    (0.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (eq, "$pop_camera_on", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (position_get_x, ":var_1", pos1),
        (position_get_y, ":var_2", pos1),
        (init_position, pos23),
        (position_set_x, pos23, ":var_1"),
        (position_set_y, pos23, ":var_2"),
        (position_set_z_to_ground_level, pos23),
        (position_move_z, pos23, 250),
        (mission_cam_set_mode, 1, 0, 0),
        (mission_cam_set_position, pos23),
        (assign, "$pop_camera_rotx", 0),
        (assign, "$pop_camera_on", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_is_down, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_is_down, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_is_down, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (game_key_is_down, gk_move_right),
    ],
    [
        (mission_cam_get_position, pos23),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_forward),
            (game_key_is_down, gk_move_forward),
            (assign, ":var_1", 10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_backward),
            (game_key_is_down, gk_move_backward),
            (assign, ":var_1", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_left),
            (game_key_is_down, gk_move_left),
            (assign, ":var_0", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_right),
            (game_key_is_down, gk_move_right),
            (assign, ":var_0", 10),
        (try_end),
        (position_move_x, pos23, ":var_0"),
        (position_move_y, pos23, ":var_1"),
        (mission_cam_set_position, pos23),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (neg|is_presentation_active, "prsnt_battle"),
        (mouse_get_position, pos1),
        (set_fixed_point_multiplier, 1000),
        (position_get_x, reg1, pos1),
        (position_get_y, reg2, pos1),
        (this_or_next|neg|eq, reg1, "$pop_camera_mouse_center_x"),
        (neg|eq, reg2, "$pop_camera_mouse_center_y"),
    ],
    [
        (assign, ":var_0", 1),
        (try_begin),
            (eq, reg1, "$pop_camera_mouse_x"),
            (eq, reg2, "$pop_camera_mouse_y"),
            (val_add, "$pop_camera_mouse_counter", 1),
            (try_begin),
                (gt, "$pop_camera_mouse_counter", 30),
                (assign, "$pop_camera_mouse_center_x", reg1),
                (assign, "$pop_camera_mouse_center_y", reg2),
                (assign, "$pop_camera_mouse_counter", 0),
            (try_end),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
        (assign, "$pop_camera_mouse_counter", 0),
        (assign, "$pop_camera_mouse_x", reg1),
        (assign, "$pop_camera_mouse_y", reg2),
        (mission_cam_get_position, pos23),
        (store_sub, ":var_1", "$pop_camera_mouse_center_x", reg1),
        (store_sub, ":var_2", reg2, "$pop_camera_mouse_center_y"),
        (try_for_range, ":var_3", 0, 2),
            (try_begin),
                (eq, ":var_3", 1),
                (assign, ":var_1", ":var_2"),
            (try_end),
            (this_or_next|neg|ge, ":var_1", -2),
            (gt, ":var_1", 2),
            (assign, ":var_4", 1),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_4", -1),
            (try_end),
            (val_abs, ":var_1"),
            (val_sub, ":var_1", 2),
            (convert_to_fixed_point, ":var_1"),
            (store_sqrt, ":var_1", ":var_1"),
            (convert_from_fixed_point, ":var_1"),
            (val_clamp, ":var_1", 1, 10),
            (val_mul, ":var_1", ":var_4"),
            (try_begin),
                (eq, ":var_3", 0),
                (store_mul, ":var_5", "$pop_camera_rotx", -1),
                (position_rotate_x, pos23, ":var_5"),
                (position_rotate_z, pos23, ":var_1"),
                (position_rotate_x, pos23, "$pop_camera_rotx"),
            (else_try),
                (position_rotate_x, pos23, ":var_1"),
                (val_add, "$pop_camera_rotx", ":var_1"),
            (try_end),
        (try_end),
        (mission_cam_set_position, pos23),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (str_store_string, s5, "str_retreat"),
        (call_script, "script_simulate_retreat", 10, 20, 1),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (assign, "$defender_reinforcement_stage", 0),
        (assign, "$attacker_reinforcement_stage", 0),
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 0.000000, 5.000000, 
    [
        (neg|ge, "$defender_reinforcement_stage", 2),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 0),
        (neg|ge, ":var_1", 6),
    ],
    [
        (add_reinforcements_to_entry, 0, 6),
        (val_add, "$defender_reinforcement_stage", 1),
    ]),

    (1.000000, 0.000000, 5.000000, 
    [
        (neg|ge, "$attacker_reinforcement_stage", 2),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 1),
        (neg|ge, ":var_1", 6),
    ],
    [
        (add_reinforcements_to_entry, 3, 6),
        (val_add, "$attacker_reinforcement_stage", 1),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (try_begin),
            (eq, "$g_village_raid_evil", 0),
            (call_script, "script_play_victorious_sound"),
        (else_try),
            (play_track, "track_victorious_evil", 1),
        (try_end),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"besiege_inner_battle_castle", 2, -1, 
"You_attack_the_walls_of_the_castle...",
[(0, mtef_attackers|mtef_team_1|mtef_use_exact_number, af_override_horse, 16, 1, []),
(6, mtef_attackers|mtef_team_1|mtef_use_exact_number, af_override_horse, 16, 1, []),
(7, mtef_attackers|mtef_team_1|mtef_use_exact_number, af_override_horse, 16, 1, []),
(16, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(17, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(18, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(19, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(20, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (str_store_string, s5, "str_retreat"),
        (call_script, "script_simulate_retreat", 5, 20, 0),
        (assign, "$g_battle_result", -1),
        (set_mission_result, -1),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (call_script, "script_music_set_situation_with_culture", 4096),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (assign, "$defender_team", 0),
        (assign, "$attacker_team", 1),
        (assign, "$defender_team_2", 2),
        (assign, "$attacker_team_2", 3),
    ],
    [
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (assign, "$pin_player_fallen", 1),
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"besiege_inner_battle_town_center", 2, -1, 
"You_attack_the_walls_of_the_castle...",
[(0, mtef_attackers|mtef_team_1|mtef_use_exact_number, af_override_horse, 16, 4, []),
(2, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(23, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(24, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(25, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(26, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(27, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
(28, mtef_defenders|mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (str_store_string, s5, "str_retreat"),
        (call_script, "script_simulate_retreat", 5, 20, 0),
        (assign, "$g_battle_result", -1),
        (set_mission_result, -1),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (call_script, "script_music_set_situation_with_culture", 4096),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (assign, "$defender_team", 0),
        (assign, "$attacker_team", 1),
        (assign, "$defender_team_2", 2),
        (assign, "$attacker_team_2", 3),
    ],
    [
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (assign, "$pin_player_fallen", 1),
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"castle_attack_walls_defenders_sally", 65538, -1, 
"You_attack_the_walls_of_the_castle...",
[(0, mtef_attackers|mtef_team_1, af_override_horse, 16, 12, []),
(0, mtef_attackers|mtef_team_1, af_override_horse, 16, 0, []),
(3, mtef_defenders|mtef_team_0, af_override_horse, 16, 12, []),
(3, mtef_defenders|mtef_team_0, af_override_horse, 16, 0, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_agent_reassign_team", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (team_set_relation, 0, 2, 1),
        (team_set_relation, 1, 3, 1),
        (call_script, "script_change_banners_and_chest"),
        (call_script, "script_remove_siege_objects"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (this_or_next|eq, "$attacker_team", "$fplayer_team_no"),
            (eq, "$attacker_team_2", "$fplayer_team_no"),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$pop_camera_on", 0),
        (assign, "$pop_camera_mouse_center_x", 500),
        (assign, "$pop_camera_mouse_center_y", 375),
        (assign, "$pop_camera_mouse_x", "$pop_camera_mouse_center_x"),
        (assign, "$pop_camera_mouse_y", "$pop_camera_mouse_center_y"),
        (assign, "$pop_camera_mouse_counter", 0),
    ]),

    (0.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (eq, "$pop_camera_on", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (position_get_x, ":var_1", pos1),
        (position_get_y, ":var_2", pos1),
        (init_position, pos23),
        (position_set_x, pos23, ":var_1"),
        (position_set_y, pos23, ":var_2"),
        (position_set_z_to_ground_level, pos23),
        (position_move_z, pos23, 250),
        (mission_cam_set_mode, 1, 0, 0),
        (mission_cam_set_position, pos23),
        (assign, "$pop_camera_rotx", 0),
        (assign, "$pop_camera_on", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_is_down, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_is_down, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_is_down, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (game_key_is_down, gk_move_right),
    ],
    [
        (mission_cam_get_position, pos23),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_forward),
            (game_key_is_down, gk_move_forward),
            (assign, ":var_1", 10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_backward),
            (game_key_is_down, gk_move_backward),
            (assign, ":var_1", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_left),
            (game_key_is_down, gk_move_left),
            (assign, ":var_0", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_right),
            (game_key_is_down, gk_move_right),
            (assign, ":var_0", 10),
        (try_end),
        (position_move_x, pos23, ":var_0"),
        (position_move_y, pos23, ":var_1"),
        (mission_cam_set_position, pos23),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (neg|is_presentation_active, "prsnt_battle"),
        (mouse_get_position, pos1),
        (set_fixed_point_multiplier, 1000),
        (position_get_x, reg1, pos1),
        (position_get_y, reg2, pos1),
        (this_or_next|neg|eq, reg1, "$pop_camera_mouse_center_x"),
        (neg|eq, reg2, "$pop_camera_mouse_center_y"),
    ],
    [
        (assign, ":var_0", 1),
        (try_begin),
            (eq, reg1, "$pop_camera_mouse_x"),
            (eq, reg2, "$pop_camera_mouse_y"),
            (val_add, "$pop_camera_mouse_counter", 1),
            (try_begin),
                (gt, "$pop_camera_mouse_counter", 30),
                (assign, "$pop_camera_mouse_center_x", reg1),
                (assign, "$pop_camera_mouse_center_y", reg2),
                (assign, "$pop_camera_mouse_counter", 0),
            (try_end),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
        (assign, "$pop_camera_mouse_counter", 0),
        (assign, "$pop_camera_mouse_x", reg1),
        (assign, "$pop_camera_mouse_y", reg2),
        (mission_cam_get_position, pos23),
        (store_sub, ":var_1", "$pop_camera_mouse_center_x", reg1),
        (store_sub, ":var_2", reg2, "$pop_camera_mouse_center_y"),
        (try_for_range, ":var_3", 0, 2),
            (try_begin),
                (eq, ":var_3", 1),
                (assign, ":var_1", ":var_2"),
            (try_end),
            (this_or_next|neg|ge, ":var_1", -2),
            (gt, ":var_1", 2),
            (assign, ":var_4", 1),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_4", -1),
            (try_end),
            (val_abs, ":var_1"),
            (val_sub, ":var_1", 2),
            (convert_to_fixed_point, ":var_1"),
            (store_sqrt, ":var_1", ":var_1"),
            (convert_from_fixed_point, ":var_1"),
            (val_clamp, ":var_1", 1, 10),
            (val_mul, ":var_1", ":var_4"),
            (try_begin),
                (eq, ":var_3", 0),
                (store_mul, ":var_5", "$pop_camera_rotx", -1),
                (position_rotate_x, pos23, ":var_5"),
                (position_rotate_z, pos23, ":var_1"),
                (position_rotate_x, pos23, "$pop_camera_rotx"),
            (else_try),
                (position_rotate_x, pos23, ":var_1"),
                (val_add, "$pop_camera_rotx", ":var_1"),
            (try_end),
        (try_end),
        (mission_cam_set_position, pos23),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (try_begin),
            (ge, ":var_0", 0),
            (neg|agent_is_ally, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_troop_id, ":var_3", ":var_0"),
            (str_store_troop_name, s6, ":var_3"),
            (assign, reg0, ":var_0"),
            (assign, reg1, ":var_1"),
            (assign, reg2, ":var_2"),
            (agent_get_team, reg3, ":var_0"),
            (party_add_members, "p_total_enemy_casualties", ":var_3", 1),
            (eq, ":var_2", 1),
            (party_wound_members, "p_total_enemy_casualties", ":var_3", 1),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (display_message, "@You can't retreat because the enemy is too close!"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (0.100000, 0.500000, ti_once, 
    [
    ],
    [
        (call_script, "script_set_player_agent_ammo", 0, 6),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 2),
        (neg|main_hero_fallen, 0),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (assign, "$g_siege_sallied_out_once", 1),
        (assign, "$g_siege_method", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (try_begin),
            (store_add, ":var_0", "p_player_casualties", "p_ally_casualties"),
            (store_add, ":var_1", ":var_0", "p_enemy_casualties"),
            (val_mul, ":var_0", 100),
            (store_div, ":var_2", ":var_0", ":var_1"),
            (ge, ":var_2", 33),
            (assign, "$g_siege_sallied_out_once", 0),
        (try_end),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_set_disciplined_faction"),
        (try_begin),
            (eq, "$g_option_formations", 1),
            (assign, "$gk_order", 0),
            (assign, "$gk_order_hold_over_there", 0),
            (assign, "$autorotate_at_player", 1),
            (assign, "$infantry_formation_type", 1),
            (assign, "$archer_formation_type", 1),
            (assign, "$cavalry_formation_type", 4),
            (assign, "$infantry_space", 2),
            (assign, "$archer_space", 2),
            (assign, "$cavalry_space", 0),
            (assign, "$fclock", 1),
            (assign, "$yield", 0),
        (try_end),
    ]),

    (0.100000, 0.000000, ti_once, 
    [
        (eq, "$g_option_formations", 1),
    ],
    [
        (assign, "$yield", 0),
        (call_script, "script_get_yield"),
        (val_div, "$yield", 4),
        (val_add, "$yield", 25),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
        (this_or_next|eq, "$g_option_formations", 0),
        (eq, "$g_disciplined_faction", 0),
    ],
    [
        (get_player_agent_no, "$fplayer_agent_no"),
        (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (set_show_messages, 0),
        (team_give_order, "$fplayer_team_no", 9, 0),
        (position_move_x, pos1, 1500),
        (position_move_y, pos1, 500),
        (team_set_order_position, "$fplayer_team_no", 2, pos1),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (position_move_x, pos1, -1500),
        (position_move_y, pos1, 500),
        (team_set_order_position, "$fplayer_team_no", 0, pos1),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (position_move_y, pos1, 2000),
        (team_set_order_position, "$fplayer_team_no", 1, pos1),
        (set_show_messages, 1),
    ]),

    (0.000000, 0.400000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (assign, ":var_0", 0),
            (assign, ":var_1", 0),
            (assign, ":var_2", 0),
            (assign, ":var_3", 0),
            (assign, "$team0_size", 0),
            (assign, "$team1_size", 0),
            (assign, "$team2_size", 0),
            (assign, "$team3_size", 0),
            (try_for_agents, ":var_4"),
                (agent_is_human, ":var_4"),
                (agent_get_team, ":var_5", ":var_4"),
                (agent_get_troop_id, ":var_6", ":var_4"),
                (store_troop_faction, ":var_7", ":var_6"),
                (try_begin),
                    (eq, ":var_5", 0),
                    (val_add, ":var_0", ":var_7"),
                    (val_add, "$team0_size", 1),
                (else_try),
                    (eq, ":var_5", 1),
                    (val_add, ":var_1", ":var_7"),
                    (val_add, "$team1_size", 1),
                (else_try),
                    (eq, ":var_5", 2),
                    (val_add, ":var_2", ":var_7"),
                    (val_add, "$team2_size", 1),
                (else_try),
                    (eq, ":var_5", 3),
                    (val_add, ":var_3", ":var_7"),
                    (val_add, "$team3_size", 1),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team0_size", 0),
                (team_get_leader, ":var_8", 0),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team0_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team0_faction", ":var_0", 10),
                    (val_div, "$team0_faction", "$team0_size"),
                    (val_add, "$team0_faction", 5),
                    (val_div, "$team0_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team1_size", 0),
                (team_get_leader, ":var_8", 1),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team1_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team1_faction", ":var_1", 10),
                    (val_div, "$team1_faction", "$team1_size"),
                    (val_add, "$team1_faction", 5),
                    (val_div, "$team1_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team2_size", 0),
                (team_get_leader, ":var_8", 2),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team2_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team2_faction", ":var_2", 10),
                    (val_div, "$team2_faction", "$team2_size"),
                    (val_add, "$team2_faction", 5),
                    (val_div, "$team2_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team3_size", 0),
                (team_get_leader, ":var_8", 3),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team3_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team3_faction", ":var_3", 10),
                    (val_div, "$team3_faction", "$team3_size"),
                    (val_add, "$team3_faction", 5),
                    (val_div, "$team3_faction", 10),
                (try_end),
            (try_end),
            (display_message, "@Forming ranks."),
            (call_script, "script_get_default_formation", "$fplayer_team_no"),
            (assign, "$infantry_formation_type", reg0),
            (call_script, "script_player_attempt_formation", 0, "$infantry_formation_type"),
            (call_script, "script_player_attempt_formation", 2, 4),
            (call_script, "script_player_attempt_formation", 1, 1),
            (set_show_messages, 0),
            (try_for_range, reg0, 3, 9),
                (team_give_order, "$fplayer_team_no", reg0, 0),
            (try_end),
            (try_for_range, reg0, 0, "$infantry_space"),
                (team_give_order, "$fplayer_team_no", 0, 8),
            (try_end),
            (try_for_range, reg0, 0, "$archer_space"),
                (team_give_order, "$fplayer_team_no", 1, 8),
            (try_end),
            (try_for_range, reg0, 0, "$cavalry_space"),
                (team_give_order, "$fplayer_team_no", 2, 8),
            (try_end),
            (set_show_messages, 1),
        (try_end),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_j),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_ranks", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 2),
        (call_script, "script_player_attempt_formation", 1, 2),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_k),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_shield", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 3),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_l),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_wedge", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 4),
        (call_script, "script_player_attempt_formation", 2, 4),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_semicolon),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_square", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 5),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_u),
    ],
    [
        (call_script, "script_player_order_formations", 2),
    ]),

    (0.000000, 0.300000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_1),
    ],
    [
        (eq, "$gk_order", 23),
        (game_key_is_down, gk_order_1),
        (assign, "$gk_order_hold_over_there", 1),
        (assign, "$gk_order", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_1),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 23),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_hold", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 0),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 24),
                (try_begin),
                    (store_random_in_range, ":var_2", 1, 101),
                    (neg|gt, ":var_2", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_advance", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 5),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_2),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 24),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_follow", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 1),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 24),
                (try_begin),
                    (store_random_in_range, ":var_2", 1, 101),
                    (neg|gt, ":var_2", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_fallback", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 6),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_3),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 25),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_charge", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 2),
            (else_try),
                (eq, "$gk_order", 24),
                (call_script, "script_player_order_formations", 8),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_4),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 23),
            (call_script, "script_player_order_formations", 11),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 24),
            (call_script, "script_player_order_formations", 7),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 25),
            (assign, "$gk_order", 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_5),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 23),
            (try_begin),
                (store_random_in_range, ":var_0", 1, 101),
                (neg|gt, ":var_0", "$yield"),
                (get_player_agent_no, ":var_1"),
                (agent_get_position, pos19, ":var_1"),
                (play_sound_at_position, "snd_th3_order_retreat", pos19),
            (try_end),
            (call_script, "script_player_order_formations", 14),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 24),
            (assign, "$gk_order", 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_6),
    ],
    [
        (eq, "$gk_order", 24),
        (try_begin),
            (class_is_listening_order, "$fplayer_team_no", 2),
            (call_script, "script_formation_end", "$fplayer_team_no", 2),
        (try_end),
        (call_script, "script_player_order_formations", 4),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_1),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (play_sound, "snd_th3_address_infantry"),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_2),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_archers", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_3),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_cavalry", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_0),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_everyone", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (this_or_next|key_clicked, key_1),
        (this_or_next|key_clicked, key_2),
        (this_or_next|key_clicked, key_3),
        (this_or_next|key_clicked, key_4),
        (this_or_next|key_clicked, key_5),
        (this_or_next|key_clicked, key_6),
        (this_or_next|key_clicked, key_7),
        (this_or_next|key_clicked, key_8),
        (this_or_next|key_clicked, key_9),
        (this_or_next|key_clicked, key_0),
        (key_clicked, key_escape),
    ],
    [
        (assign, "$gk_order", 0),
    ]),

    (0.500000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$gk_order_hold_over_there", 1),
        (neg|game_key_is_down, gk_order_1),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (play_sound, "snd_th3_order_hold"),
        (try_end),
        (call_script, "script_team_get_average_position_of_enemies_augmented", 60, "$fplayer_team_no", 9),
        (assign, ":var_1", 0),
        (try_for_range, reg0, 0, 9),
            (class_is_listening_order, "$fplayer_team_no", reg0),
            (val_add, ":var_1", 1),
        (try_end),
        (agent_get_position, pos22, "$fplayer_agent_no"),
        (try_begin),
            (neg|eq, "$infantry_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 0),
            (team_get_order_position, pos2, "$fplayer_team_no", 0),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 0, "$infantry_space", "$infantry_formation_type"),
                (try_end),
            (else_try),
                (assign, ":var_2", 0),
                (try_for_agents, reg0),
                    (call_script, "script_cf_valid_formation_member", "$fplayer_team_no", 0, "$fplayer_agent_no", reg0),
                    (val_add, ":var_2", 1),
                (try_end),
                (call_script, "script_get_centering_amount", "$infantry_formation_type", ":var_2", "$infantry_space"),
                (position_move_x, pos2, reg0),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 0, 1),
                (call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
            (try_end),
            (assign, "$infantry_formation_move_order", 0),
        (try_end),
        (try_begin),
            (neg|eq, "$cavalry_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 2),
            (team_get_order_position, pos2, "$fplayer_team_no", 2),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 2, "$cavalry_space", "$cavalry_formation_type"),
                (try_end),
            (else_try),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 2, 1),
                (call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
            (try_end),
            (assign, "$cavalry_formation_move_order", 0),
        (try_end),
        (try_begin),
            (neg|eq, "$archer_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 1),
            (team_get_order_position, pos2, "$fplayer_team_no", 1),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 1, "$archer_space", "$archer_formation_type"),
                (try_end),
            (else_try),
                (assign, ":var_2", 0),
                (try_for_agents, reg0),
                    (call_script, "script_cf_valid_formation_member", "$fplayer_team_no", 1, "$fplayer_agent_no", reg0),
                    (val_add, ":var_2", 1),
                (try_end),
                (call_script, "script_get_centering_amount", 1, ":var_2", "$archer_space"),
                (val_mul, reg0, -1),
                (position_move_x, pos2, reg0),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 1, 1),
                (call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space", "$archer_formation_type"),
            (try_end),
            (assign, "$archer_formation_move_order", 0),
        (try_end),
        (agent_set_position, "$fplayer_agent_no", pos22),
        (assign, "$gk_order_hold_over_there", 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (neg|key_is_down, key_j),
        (neg|key_is_down, key_k),
        (neg|key_is_down, key_l),
        (neg|key_is_down, key_semicolon),
        (neg|key_is_down, key_u),
        (neg|game_key_is_down, gk_order_1),
        (neg|game_key_is_down, gk_order_2),
        (neg|game_key_is_down, gk_order_3),
        (neg|game_key_is_down, gk_order_4),
        (neg|game_key_is_down, gk_order_5),
        (neg|game_key_is_down, gk_order_6),
    ],
    [
        (set_fixed_point_multiplier, 100),
        (store_mod, ":var_0", "$fclock", 5),
        (call_script, "script_team_get_average_position_of_enemies_augmented", 60, "$fplayer_team_no", 9),
        (try_begin),
            (eq, reg0, 0),
            (neg|eq, "$g_encountered_party", -1),
            (call_script, "script_formation_end", "$fplayer_team_no", 9),
        (else_try),
            (assign, "$autorotate_at_player", 0),
            (try_begin),
                (neg|eq, "$infantry_formation_type", 0),
                (try_begin),
                    (eq, "$infantry_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 0, "$infantry_space", "$infantry_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 0),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 0),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 0, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, "$cavalry_formation_type", 0),
                (try_begin),
                    (eq, "$cavalry_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 2, "$cavalry_space", "$cavalry_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 2),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 2),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 2, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, "$archer_formation_type", 0),
                (try_begin),
                    (eq, "$archer_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 1, "$archer_space", "$archer_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 1),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 1),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 1, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space", "$archer_formation_type"),
                (try_end),
            (try_end),
            (assign, "$autorotate_at_player", 1),
        (try_end),
        (val_add, "$fclock", 1),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (assign, "$cur_casualties", 0),
            (assign, "$prev_casualties", 0),
            (assign, "$prev_casualties2", 0),
            (assign, "$ranged_clock", 1),
            (assign, "$battle_phase", 1),
            (assign, "$clock_reset", 0),
            (assign, "$charge_activated", 0),
            (assign, "$charge_ongoing", 0),
            (assign, "$inf_charge_activated", 0),
            (assign, "$inf_charge_ongoing", 0),
            (assign, "$arc_charge_activated", 0),
            (assign, "$att_reinforcements_arrived", 0),
            (assign, "$def_reinforcements_arrived", 0),
            (assign, "$att_reinforcements_needed", 0),
            (assign, "$def_reinforcements_needed", 0),
            (assign, "$disengage", 0),
            (assign, "$patrol_mode", 0),
            (store_random_in_range, "$rand0", -1000, 1000),
            (store_random_in_range, "$rand2", 800, 1501),
            (store_random_in_range, "$rand1", 0, 501),
            (store_random_in_range, "$rand3", 2000, 3001),
            (store_random_in_range, "$rand4", 1000, 3001),
            (store_random_in_range, "$rand5", -1000, 0),
            (store_random_in_range, "$rand6", 4000, 5001),
            (store_random_in_range, "$rand7", 49, 56),
            (store_random_in_range, "$rand8", -100, 101),
            (assign, "$team0_default_formation", 1),
            (assign, "$team1_default_formation", 1),
            (assign, "$team2_default_formation", 1),
            (assign, "$team3_default_formation", 1),
            (init_position, pos56),
            (init_position, pos57),
            (init_position, pos58),
            (init_position, pos59),
            (assign, "$team0_reinforcement_stage", 0),
            (assign, "$team1_reinforcement_stage", 0),
            (init_position, pos17),
            (init_position, pos18),
        (try_end),
    ]),

    (0.000000, 0.500000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (eq, "$g_disciplined_faction", 1),
            (try_for_agents, ":var_0"),
                (agent_set_slot, ":var_0", slot_agent_is_running_away, 0),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (call_script, "script_store_battlegroup_data"),
            (call_script, "script_battlegroup_get_position", 12, 0, 9),
            (call_script, "script_battlegroup_get_position", 13, 1, 9),
            (call_script, "script_battlegroup_get_position", 14, 2, 9),
            (call_script, "script_battlegroup_get_position", 16, 3, 9),
            (call_script, "script_field_tactics", 1),
        (try_end),
    ]),

    (60.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$g_disciplined_faction", 1),
    ],
    [
        (store_random_in_range, "$rand0", -1000, 1000),
        (store_random_in_range, "$rand2", 800, 1501),
        (store_random_in_range, "$rand1", -1000, 1000),
        (store_random_in_range, "$rand3", 2000, 3001),
        (store_random_in_range, "$rand4", 1000, 3001),
        (store_random_in_range, "$rand5", -1000, 0),
        (store_random_in_range, "$rand6", 4000, 5001),
        (store_random_in_range, "$rand7", 45, 56),
        (store_random_in_range, "$rand8", -100, 101),
    ]),

    (1.000000, 0.900000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$g_disciplined_faction", 1),
    ],
    [
        (try_begin),
            (assign, "$prev_casualties2", "$cur_casualties"),
            (call_script, "script_cf_count_casualties"),
            (assign, "$cur_casualties", reg0),
            (assign, "$battle_phase", 3),
        (try_end),
        (set_fixed_point_multiplier, 100),
        (call_script, "script_store_battlegroup_data"),
        (try_begin),
            (eq, "$battle_phase", 3),
            (eq, "$clock_reset", 0),
            (call_script, "script_field_tactics", 1),
            (assign, "$ranged_clock", 0),
            (assign, "$clock_reset", 1),
        (else_try),
            (ge, "$battle_phase", 2),
            (store_mod, reg0, "$ranged_clock", 5),
            (eq, reg0, 0),
            (call_script, "script_field_tactics", 1),
            (assign, "$team0_reinforcement_stage", "$defender_reinforcement_stage"),
            (assign, "$team1_reinforcement_stage", "$attacker_reinforcement_stage"),
        (else_try),
            (call_script, "script_field_tactics", 0),
        (try_end),
        (try_begin),
            (eq, "$battle_phase", 1),
            (assign, ":var_0", 0),
            (try_for_range, ":var_1", 0, 4),
                (neg|eq, ":var_1", "$fplayer_team_no"),
                (call_script, "script_battlegroup_get_size", ":var_1", 9),
                (gt, reg0, 0),
                (call_script, "script_battlegroup_get_position", 1, ":var_1", 1),
                (team_get_order_position, pos0, ":var_1", 1),
                (get_distance_between_positions, reg0, pos0, pos1),
                (gt, reg0, 500),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 0),
            (assign, "$battle_phase", 2),
        (try_end),
        (val_add, "$ranged_clock", 1),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"castle_attack_walls_belfry", 65538, -1, 
"You_attack_the_walls_of_the_castle...",
[(0, mtef_attackers|mtef_team_1, af_override_horse, 16, 12, []),
(0, mtef_attackers|mtef_team_1, af_override_horse, 16, 0, []),
(10, mtef_defenders|mtef_team_0, af_override_horse, 16, 0, []),
(11, mtef_defenders|mtef_team_0, af_override_horse, 16, 7, []),
(15, mtef_defenders|mtef_team_0, af_override_horse, 16, 0, []),
(40, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(41, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(42, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(43, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(44, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(45, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(46, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(47, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
],
[
    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$pop_camera_on", 0),
        (assign, "$pop_camera_mouse_center_x", 500),
        (assign, "$pop_camera_mouse_center_y", 375),
        (assign, "$pop_camera_mouse_x", "$pop_camera_mouse_center_x"),
        (assign, "$pop_camera_mouse_y", "$pop_camera_mouse_center_y"),
        (assign, "$pop_camera_mouse_counter", 0),
    ]),

    (0.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (eq, "$pop_camera_on", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (position_get_x, ":var_1", pos1),
        (position_get_y, ":var_2", pos1),
        (init_position, pos23),
        (position_set_x, pos23, ":var_1"),
        (position_set_y, pos23, ":var_2"),
        (position_set_z_to_ground_level, pos23),
        (position_move_z, pos23, 250),
        (mission_cam_set_mode, 1, 0, 0),
        (mission_cam_set_position, pos23),
        (assign, "$pop_camera_rotx", 0),
        (assign, "$pop_camera_on", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_is_down, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_is_down, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_is_down, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (game_key_is_down, gk_move_right),
    ],
    [
        (mission_cam_get_position, pos23),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_forward),
            (game_key_is_down, gk_move_forward),
            (assign, ":var_1", 10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_backward),
            (game_key_is_down, gk_move_backward),
            (assign, ":var_1", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_left),
            (game_key_is_down, gk_move_left),
            (assign, ":var_0", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_right),
            (game_key_is_down, gk_move_right),
            (assign, ":var_0", 10),
        (try_end),
        (position_move_x, pos23, ":var_0"),
        (position_move_y, pos23, ":var_1"),
        (mission_cam_set_position, pos23),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (neg|is_presentation_active, "prsnt_battle"),
        (mouse_get_position, pos1),
        (set_fixed_point_multiplier, 1000),
        (position_get_x, reg1, pos1),
        (position_get_y, reg2, pos1),
        (this_or_next|neg|eq, reg1, "$pop_camera_mouse_center_x"),
        (neg|eq, reg2, "$pop_camera_mouse_center_y"),
    ],
    [
        (assign, ":var_0", 1),
        (try_begin),
            (eq, reg1, "$pop_camera_mouse_x"),
            (eq, reg2, "$pop_camera_mouse_y"),
            (val_add, "$pop_camera_mouse_counter", 1),
            (try_begin),
                (gt, "$pop_camera_mouse_counter", 30),
                (assign, "$pop_camera_mouse_center_x", reg1),
                (assign, "$pop_camera_mouse_center_y", reg2),
                (assign, "$pop_camera_mouse_counter", 0),
            (try_end),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
        (assign, "$pop_camera_mouse_counter", 0),
        (assign, "$pop_camera_mouse_x", reg1),
        (assign, "$pop_camera_mouse_y", reg2),
        (mission_cam_get_position, pos23),
        (store_sub, ":var_1", "$pop_camera_mouse_center_x", reg1),
        (store_sub, ":var_2", reg2, "$pop_camera_mouse_center_y"),
        (try_for_range, ":var_3", 0, 2),
            (try_begin),
                (eq, ":var_3", 1),
                (assign, ":var_1", ":var_2"),
            (try_end),
            (this_or_next|neg|ge, ":var_1", -2),
            (gt, ":var_1", 2),
            (assign, ":var_4", 1),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_4", -1),
            (try_end),
            (val_abs, ":var_1"),
            (val_sub, ":var_1", 2),
            (convert_to_fixed_point, ":var_1"),
            (store_sqrt, ":var_1", ":var_1"),
            (convert_from_fixed_point, ":var_1"),
            (val_clamp, ":var_1", 1, 10),
            (val_mul, ":var_1", ":var_4"),
            (try_begin),
                (eq, ":var_3", 0),
                (store_mul, ":var_5", "$pop_camera_rotx", -1),
                (position_rotate_x, pos23, ":var_5"),
                (position_rotate_z, pos23, ":var_1"),
                (position_rotate_x, pos23, "$pop_camera_rotx"),
            (else_try),
                (position_rotate_x, pos23, ":var_1"),
                (val_add, "$pop_camera_rotx", ":var_1"),
            (try_end),
        (try_end),
        (mission_cam_set_position, pos23),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (team_set_relation, 0, 2, 1),
        (team_set_relation, 1, 3, 1),
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (this_or_next|eq, "$attacker_team", "$fplayer_team_no"),
            (eq, "$attacker_team_2", "$fplayer_team_no"),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (get_player_agent_no, ":var_1"),
        (agent_get_team, ":var_2", ":var_1"),
        (try_begin),
            (neg|eq, "$attacker_team", ":var_2"),
            (neg|eq, "$attacker_team_2", ":var_2"),
            (str_store_string, s5, "str_siege_continues"),
            (call_script, "script_simulate_retreat", 8, 15, 0),
        (else_try),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 5, 20, 0),
            (call_script, "script_change_troop_renown", "trp_player", -20),
            (call_script, "script_change_player_honor", -2),
            (call_script, "script_change_player_party_morale", -15),
            (troop_get_slot, ":var_3", "trp_player", slot_troop_days_on_mission),
            (store_random_in_range, ":var_4", 0, 3),
            (try_begin),
                (gt, ":var_4", 0),
                (val_add, ":var_3", ":var_4"),
                (val_min, ":var_3", 100),
                (troop_set_slot, "trp_player", slot_troop_days_on_mission, ":var_3"),
                (display_message, "@Your controversy has increased due to this retreat.", 0xFF5050),
            (try_end),
            (eq, "$pop_kingdom", 1),
            (try_for_range, ":var_5", "trp_npc_adonja", "trp_knight_1_1_wife"),
                (troop_slot_eq, ":var_5", slot_troop_occupation, 2),
                (store_troop_faction, ":var_6", ":var_5"),
                (eq, ":var_6", "fac_player_supporters_faction"),
                (store_random_in_range, ":var_4", 1, 11),
                (ge, ":var_4", 9),
                (call_script, "script_troop_change_relation_with_troop", "trp_player", ":var_5", -1),
            (try_end),
        (try_end),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (assign, "$defender_reinforcement_stage", 0),
        (assign, "$attacker_reinforcement_stage", 0),
        (call_script, "script_music_set_situation_with_culture", 262144),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (assign, "$defender_team", 0),
        (assign, "$attacker_team", 1),
        (assign, "$defender_team_2", 2),
        (assign, "$attacker_team_2", 3),
        (try_begin),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (this_or_next|eq, "$attacker_team", "$fplayer_team_no"),
            (eq, "$attacker_team_2", "$fplayer_team_no"),
            (agent_get_position, pos1, "$fplayer_agent_no"),
            (set_show_messages, 0),
            (team_give_order, "$fplayer_team_no", 9, 0),
            (position_move_y, pos1, 500),
            (team_set_order_position, "$fplayer_team_no", 0, pos1),
            (agent_get_position, pos1, "$fplayer_agent_no"),
            (position_move_y, pos1, 100),
            (team_set_order_position, "$fplayer_team_no", 1, pos1),
            (team_give_order, "$fplayer_team_no", 1, 8),
            (set_show_messages, 1),
        (else_try),
            (entry_point_get_position, pos1, 15),
            (set_spawn_position, pos1),
            (spawn_scene_prop, "spr_inventory", 0),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (set_show_messages, 0),
        (entry_point_get_position, pos10, 10),
        (try_for_range, ":var_0", 0, 9),
            (neg|eq, ":var_0", 1),
            (team_give_order, "$defender_team", ":var_0", 0),
            (team_give_order, "$defender_team", ":var_0", 7),
            (team_give_order, "$defender_team", ":var_0", 7),
            (team_give_order, "$defender_team_2", ":var_0", 0),
            (team_give_order, "$defender_team_2", ":var_0", 7),
            (team_give_order, "$defender_team_2", ":var_0", 7),
        (try_end),
        (team_give_order, "$defender_team", 1, 11),
        (team_set_order_position, "$defender_team", 9, pos10),
        (team_give_order, "$defender_team_2", 1, 11),
        (team_set_order_position, "$defender_team_2", 9, pos10),
        (set_show_messages, 1),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (set_show_messages, 0),
        (team_give_order, "$attacker_team", 9, 8),
        (team_give_order, "$attacker_team", 9, 8),
        (team_give_order, "$attacker_team", 9, 8),
        (set_show_messages, 1),
    ],
    [
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (try_begin),
            (ge, ":var_0", 0),
            (neg|agent_is_ally, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_troop_id, ":var_3", ":var_0"),
            (str_store_troop_name, s6, ":var_3"),
            (assign, reg0, ":var_0"),
            (assign, reg1, ":var_1"),
            (assign, reg2, ":var_2"),
            (agent_get_team, reg3, ":var_0"),
            (party_add_members, "p_total_enemy_casualties", ":var_3", 1),
            (eq, ":var_2", 1),
            (party_wound_members, "p_total_enemy_casualties", ":var_3", 1),
        (try_end),
    ]),

    (0.000000, 2.000000, ti_once, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_set_slot, ":var_0", slot_agent_is_not_reinforcement, 1),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (neg|ge, "$defender_reinforcement_stage", 20),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 0),
        (neg|ge, ":var_1", 12),
        (add_reinforcements_to_entry, 4, 7),
        (val_add, "$defender_reinforcement_stage", 1),
        (try_begin),
            (gt, ":var_0", 300),
            (get_player_agent_no, ":var_2"),
            (agent_get_team, ":var_3", ":var_2"),
            (neg|eq, ":var_3", "$defender_team"),
            (neg|eq, ":var_3", "$defender_team_2"),
            (ge, "$defender_reinforcement_stage", 2),
            (set_show_messages, 0),
            (team_give_order, "$defender_team", 0, 2),
            (team_give_order, "$defender_team_2", 0, 2),
            (team_give_order, "$defender_team", 2, 2),
            (team_give_order, "$defender_team_2", 2, 2),
            (set_show_messages, 1),
            (ge, "$defender_reinforcement_stage", 4),
            (set_show_messages, 0),
            (team_give_order, "$defender_team", 9, 2),
            (team_give_order, "$defender_team_2", 9, 2),
            (set_show_messages, 1),
        (try_end),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_siege_move_archers_to_archer_positions"),
    ]),

    (1.000000, 0.000000, 5.000000, 
    [
        (neg|ge, "$attacker_reinforcement_stage", 15),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 1),
        (neg|ge, ":var_1", 8),
    ],
    [
        (add_reinforcements_to_entry, 1, 8),
        (val_add, "$attacker_reinforcement_stage", 1),
    ]),

    (5.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_team, ":var_1", ":var_0"),
            (this_or_next|eq, ":var_1", "$attacker_team"),
            (eq, ":var_1", "$attacker_team_2"),
            (agent_ai_set_always_attack_in_melee, ":var_0", 1),
        (try_end),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (60.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (this_or_next|eq, ":var_2", "$defender_team"),
            (eq, ":var_2", "$defender_team_2"),
            (agent_refill_ammo, ":var_1"),
        (try_end),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (assign, "$pin_player_fallen", 1),
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (call_script, "script_siege_init_ai_and_belfry"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (call_script, "script_cf_siege_move_belfry"),
    ],
    [
    ]),

    (0.000000, 2.000000, ti_once, 
    [
        (call_script, "script_cf_siege_rotate_belfry_platform"),
    ],
    [
        (assign, "$belfry_positioned", 3),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (call_script, "script_cf_siege_assign_men_to_belfry"),
    ],
    [
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"castle_attack_walls_ladder", 65538, -1, 
"You_attack_the_walls_of_the_castle...",
[(0, mtef_attackers|mtef_team_1, af_override_horse, 16, 12, []),
(0, mtef_attackers|mtef_team_1, af_override_horse, 16, 0, []),
(10, mtef_defenders|mtef_team_0, af_override_horse, 16, 0, []),
(11, mtef_defenders|mtef_team_0, af_override_horse, 16, 7, []),
(15, mtef_defenders|mtef_team_0, af_override_horse, 16, 0, []),
(40, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(41, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(42, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(43, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(44, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(45, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
(46, mtef_defenders|mtef_team_0|mtef_archers_first, af_override_horse, 16, 1, []),
],
[
    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$pop_camera_on", 0),
        (assign, "$pop_camera_mouse_center_x", 500),
        (assign, "$pop_camera_mouse_center_y", 375),
        (assign, "$pop_camera_mouse_x", "$pop_camera_mouse_center_x"),
        (assign, "$pop_camera_mouse_y", "$pop_camera_mouse_center_y"),
        (assign, "$pop_camera_mouse_counter", 0),
    ]),

    (0.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (eq, "$pop_camera_on", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (position_get_x, ":var_1", pos1),
        (position_get_y, ":var_2", pos1),
        (init_position, pos23),
        (position_set_x, pos23, ":var_1"),
        (position_set_y, pos23, ":var_2"),
        (position_set_z_to_ground_level, pos23),
        (position_move_z, pos23, 250),
        (mission_cam_set_mode, 1, 0, 0),
        (mission_cam_set_position, pos23),
        (assign, "$pop_camera_rotx", 0),
        (assign, "$pop_camera_on", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_is_down, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_is_down, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_is_down, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (game_key_is_down, gk_move_right),
    ],
    [
        (mission_cam_get_position, pos23),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_forward),
            (game_key_is_down, gk_move_forward),
            (assign, ":var_1", 10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_backward),
            (game_key_is_down, gk_move_backward),
            (assign, ":var_1", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_left),
            (game_key_is_down, gk_move_left),
            (assign, ":var_0", -10),
        (try_end),
        (try_begin),
            (this_or_next|game_key_clicked, gk_move_right),
            (game_key_is_down, gk_move_right),
            (assign, ":var_0", 10),
        (try_end),
        (position_move_x, pos23, ":var_0"),
        (position_move_y, pos23, ":var_1"),
        (mission_cam_set_position, pos23),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$pop_camera_on", 1),
        (neg|is_presentation_active, "prsnt_battle"),
        (mouse_get_position, pos1),
        (set_fixed_point_multiplier, 1000),
        (position_get_x, reg1, pos1),
        (position_get_y, reg2, pos1),
        (this_or_next|neg|eq, reg1, "$pop_camera_mouse_center_x"),
        (neg|eq, reg2, "$pop_camera_mouse_center_y"),
    ],
    [
        (assign, ":var_0", 1),
        (try_begin),
            (eq, reg1, "$pop_camera_mouse_x"),
            (eq, reg2, "$pop_camera_mouse_y"),
            (val_add, "$pop_camera_mouse_counter", 1),
            (try_begin),
                (gt, "$pop_camera_mouse_counter", 30),
                (assign, "$pop_camera_mouse_center_x", reg1),
                (assign, "$pop_camera_mouse_center_y", reg2),
                (assign, "$pop_camera_mouse_counter", 0),
            (try_end),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
        (assign, "$pop_camera_mouse_counter", 0),
        (assign, "$pop_camera_mouse_x", reg1),
        (assign, "$pop_camera_mouse_y", reg2),
        (mission_cam_get_position, pos23),
        (store_sub, ":var_1", "$pop_camera_mouse_center_x", reg1),
        (store_sub, ":var_2", reg2, "$pop_camera_mouse_center_y"),
        (try_for_range, ":var_3", 0, 2),
            (try_begin),
                (eq, ":var_3", 1),
                (assign, ":var_1", ":var_2"),
            (try_end),
            (this_or_next|neg|ge, ":var_1", -2),
            (gt, ":var_1", 2),
            (assign, ":var_4", 1),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_4", -1),
            (try_end),
            (val_abs, ":var_1"),
            (val_sub, ":var_1", 2),
            (convert_to_fixed_point, ":var_1"),
            (store_sqrt, ":var_1", ":var_1"),
            (convert_from_fixed_point, ":var_1"),
            (val_clamp, ":var_1", 1, 10),
            (val_mul, ":var_1", ":var_4"),
            (try_begin),
                (eq, ":var_3", 0),
                (store_mul, ":var_5", "$pop_camera_rotx", -1),
                (position_rotate_x, pos23, ":var_5"),
                (position_rotate_z, pos23, ":var_1"),
                (position_rotate_x, pos23, "$pop_camera_rotx"),
            (else_try),
                (position_rotate_x, pos23, ":var_1"),
                (val_add, "$pop_camera_rotx", ":var_1"),
            (try_end),
        (try_end),
        (mission_cam_set_position, pos23),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (team_set_relation, 0, 2, 1),
        (team_set_relation, 1, 3, 1),
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (main_hero_fallen),
            (assign, "$pin_player_fallen", 1),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 10, 20, 0),
            (assign, "$g_battle_result", -1),
            (set_mission_result, -1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission, 0),
        (else_try),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (this_or_next|eq, "$attacker_team", "$fplayer_team_no"),
            (eq, "$attacker_team_2", "$fplayer_team_no"),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box, "str_do_you_want_to_retreat"),
        (else_try),
            (display_message, "str_can_not_retreat"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$pin_player_fallen", 0),
        (get_player_agent_no, ":var_1"),
        (agent_get_team, ":var_2", ":var_1"),
        (try_begin),
            (neg|eq, "$attacker_team", ":var_2"),
            (neg|eq, "$attacker_team_2", ":var_2"),
            (str_store_string, s5, "str_siege_continues"),
            (call_script, "script_simulate_retreat", 8, 15, 0),
        (else_try),
            (str_store_string, s5, "str_retreat"),
            (call_script, "script_simulate_retreat", 5, 20, 0),
            (call_script, "script_change_troop_renown", "trp_player", -20),
            (call_script, "script_change_player_honor", -2),
            (call_script, "script_change_player_party_morale", -15),
            (troop_get_slot, ":var_3", "trp_player", slot_troop_days_on_mission),
            (store_random_in_range, ":var_4", 0, 3),
            (try_begin),
                (gt, ":var_4", 0),
                (val_add, ":var_3", ":var_4"),
                (val_min, ":var_3", 100),
                (troop_set_slot, "trp_player", slot_troop_days_on_mission, ":var_3"),
                (display_message, "@Your controversy has increased due to this retreat.", 0xFF5050),
            (try_end),
            (eq, "$pop_kingdom", 1),
            (try_for_range, ":var_5", "trp_npc_adonja", "trp_knight_1_1_wife"),
                (troop_slot_eq, ":var_5", slot_troop_occupation, 2),
                (store_troop_faction, ":var_6", ":var_5"),
                (eq, ":var_6", "fac_player_supporters_faction"),
                (store_random_in_range, ":var_4", 1, 11),
                (ge, ":var_4", 9),
                (call_script, "script_troop_change_relation_with_troop", "trp_player", ":var_5", -1),
            (try_end),
        (try_end),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 0),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_won", 0),
        (assign, "$defender_reinforcement_stage", 0),
        (assign, "$attacker_reinforcement_stage", 0),
        (call_script, "script_music_set_situation_with_culture", 262144),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (assign, "$defender_team", 0),
        (assign, "$attacker_team", 1),
        (assign, "$defender_team_2", 2),
        (assign, "$attacker_team_2", 3),
        (try_begin),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (this_or_next|eq, "$attacker_team", "$fplayer_team_no"),
            (eq, "$attacker_team_2", "$fplayer_team_no"),
            (agent_get_position, pos1, "$fplayer_agent_no"),
            (set_show_messages, 0),
            (team_give_order, "$fplayer_team_no", 9, 0),
            (position_move_y, pos1, 500),
            (team_set_order_position, "$fplayer_team_no", 0, pos1),
            (agent_get_position, pos1, "$fplayer_agent_no"),
            (position_move_y, pos1, 100),
            (team_set_order_position, "$fplayer_team_no", 1, pos1),
            (team_give_order, "$fplayer_team_no", 1, 8),
            (set_show_messages, 1),
        (else_try),
            (entry_point_get_position, pos1, 15),
            (set_spawn_position, pos1),
            (spawn_scene_prop, "spr_inventory", 0),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (set_show_messages, 0),
        (entry_point_get_position, pos10, 10),
        (try_for_range, ":var_0", 0, 9),
            (neg|eq, ":var_0", 1),
            (team_give_order, "$defender_team", ":var_0", 0),
            (team_give_order, "$defender_team", ":var_0", 7),
            (team_give_order, "$defender_team", ":var_0", 7),
            (team_give_order, "$defender_team_2", ":var_0", 0),
            (team_give_order, "$defender_team_2", ":var_0", 7),
            (team_give_order, "$defender_team_2", ":var_0", 7),
        (try_end),
        (team_give_order, "$defender_team", 1, 11),
        (team_set_order_position, "$defender_team", 9, pos10),
        (team_give_order, "$defender_team_2", 1, 11),
        (team_set_order_position, "$defender_team_2", 9, pos10),
        (set_show_messages, 1),
    ],
    [
    ]),

    (0.000000, 2.000000, ti_once, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_set_slot, ":var_0", slot_agent_is_not_reinforcement, 1),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (neg|ge, "$defender_reinforcement_stage", 20),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 0),
        (neg|ge, ":var_1", 10),
        (add_reinforcements_to_entry, 4, 7),
        (val_add, "$defender_reinforcement_stage", 1),
        (try_begin),
            (gt, ":var_0", 300),
            (get_player_agent_no, ":var_2"),
            (agent_get_team, ":var_3", ":var_2"),
            (neg|eq, ":var_3", "$defender_team"),
            (neg|eq, ":var_3", "$defender_team_2"),
            (ge, "$defender_reinforcement_stage", 2),
            (set_show_messages, 0),
            (team_give_order, "$defender_team", 0, 2),
            (team_give_order, "$defender_team_2", 0, 2),
            (team_give_order, "$defender_team", 2, 2),
            (team_give_order, "$defender_team_2", 2, 2),
            (set_show_messages, 1),
            (ge, "$defender_reinforcement_stage", 4),
            (set_show_messages, 0),
            (team_give_order, "$defender_team", 9, 2),
            (team_give_order, "$defender_team_2", 9, 2),
            (set_show_messages, 1),
        (try_end),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_siege_move_archers_to_archer_positions"),
    ]),

    (1.000000, 0.000000, 5.000000, 
    [
        (neg|ge, "$attacker_reinforcement_stage", 20),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (store_normalized_team_count, ":var_1", 1),
        (neg|ge, ":var_1", 8),
    ],
    [
        (add_reinforcements_to_entry, 1, 8),
        (val_add, "$attacker_reinforcement_stage", 1),
    ]),

    (5.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_team, ":var_1", ":var_0"),
            (this_or_next|eq, ":var_1", "$attacker_team"),
            (eq, ":var_1", "$attacker_team_2"),
            (agent_ai_set_always_attack_in_melee, ":var_0", 1),
        (try_end),
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_check_friendly_kills"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 5),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
        (call_script, "script_play_victorious_sound"),
    ],
    [
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (60.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (this_or_next|eq, ":var_2", "$defender_team"),
            (eq, ":var_2", "$defender_team_2"),
            (agent_refill_ammo, ":var_1"),
        (try_end),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (assign, "$pin_player_fallen", 1),
        (display_message, "@You have fallen in battle!"),
        (team_give_order, "$fplayer_team_no", 9, 2),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (try_begin),
            (ge, ":var_0", 0),
            (neg|agent_is_ally, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_troop_id, ":var_3", ":var_0"),
            (str_store_troop_name, s6, ":var_3"),
            (assign, reg0, ":var_0"),
            (assign, reg1, ":var_1"),
            (assign, reg2, ":var_2"),
            (agent_get_team, reg3, ":var_0"),
            (party_add_members, "p_total_enemy_casualties", ":var_3", 1),
            (eq, ":var_2", 1),
            (party_wound_members, "p_total_enemy_casualties", ":var_3", 1),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"castle_visit", 0, -1, 
"Castle_visit",
[(0, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_head|af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(1, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(2, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(3, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(4, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(5, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(6, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(7, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(8, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(9, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(10, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(11, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(12, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(13, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(14, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(15, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(16, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(17, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(18, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(19, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(20, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(21, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(22, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(23, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(24, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(25, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(26, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(27, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(28, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(29, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(30, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(31, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(32, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(33, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(34, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(35, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(36, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(37, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(38, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(39, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(40, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(41, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(42, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(43, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(44, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(45, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(46, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_init_town_agent", ":var_0"),
        (get_player_agent_no, ":var_1"),
        (try_begin),
            (neg|eq, ":var_1", ":var_0"),
            (agent_set_team, ":var_0", 7),
        (try_end),
        (try_begin),
            (this_or_next|eq, "$talk_context", 19),
            (eq, "$talk_context", 18),
            (agent_get_troop_id, ":var_2", ":var_0"),
            (troop_get_slot, ":var_3", ":var_2", 155),
            (eq, ":var_3", 1),
            (agent_set_team, ":var_0", 0),
            (agent_ai_set_aggressiveness, ":var_0", 5),
            (troop_set_slot, ":var_2", 155, 0),
            (try_begin),
                (troop_slot_eq, ":var_2", slot_troop_mission_participation, 3),
                (agent_get_position, pos1, ":var_0"),
                (agent_set_scripted_destination, ":var_0", pos1),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_get_troop_id, ":var_2", ":var_0"),
        (agent_get_troop_id, ":var_3", ":var_1"),
        (try_begin),
            (this_or_next|eq, ":var_2", "trp_sarleon_prison_guard"),
            (this_or_next|eq, ":var_2", "trp_rav_prison_guard"),
            (this_or_next|eq, ":var_2", "trp_dshar_prison_guard"),
            (this_or_next|eq, ":var_2", "trp_fierd_prison_guard"),
            (eq, ":var_2", "trp_empire_prison_guard"),
            (eq, ":var_3", "trp_player"),
            (display_message, "@You got the keys to the dungeon."),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (this_or_next|eq, "$talk_context", 18),
        (eq, "$talk_context", 19),
    ],
    [
        (call_script, "script_neutral_behavior_in_fight"),
        (mission_disable_talk),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
        (eq, "$talk_context", 19),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (assign, reg6, ":var_0"),
        (call_script, "script_activate_town_guard"),
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos4, ":var_0"),
        (try_for_range, ":var_1", "trp_npc_adonja", "trp_heroes_end"),
            (troop_slot_ge, ":var_1", slot_troop_mission_participation, 1),
            (str_store_troop_name, s4, ":var_1"),
            (display_message, "str_s4_joins_prison_break"),
            (store_current_scene, ":var_2"),
            (modify_visitors_at_site, ":var_2"),
            (store_current_scene, ":var_2"),
            (modify_visitors_at_site, ":var_2"),
            (assign, ":var_3", 24),
            (add_visitors_to_current_scene, ":var_3", ":var_1", 1, 0, 0),
            (troop_set_slot, ":var_1", 155, 1),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (this_or_next|eq, "$talk_context", 19),
            (eq, "$talk_context", 18),
            (display_message, "str_cannot_leave_now"),
        (else_try),
            (this_or_next|eq, "$g_mt_mode", 0),
            (eq, "$g_mt_mode", 1),
            (set_trigger_result, 1),
            (mission_enable_talk),
        (else_try),
            (display_message, "str_cannot_leave_now"),
        (try_end),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
        (call_script, "script_remove_siege_objects"),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (main_hero_fallen, 0),
    ],
    [
        (try_begin),
            (this_or_next|eq, "$talk_context", 18),
            (eq, "$talk_context", 19),
            (call_script, "script_deduct_casualties_from_garrison"),
            (jump_to_menu, "mnu_captivity_start_castle_defeat"),
            (assign, ":var_0", "trp_heroes_end"),
            (try_for_range, ":var_1", "trp_npc_adonja", ":var_0"),
                (troop_set_slot, ":var_1", slot_troop_mission_participation, 0),
            (try_end),
            (mission_enable_talk),
            (finish_mission, 0),
        (else_try),
            (mission_enable_talk),
            (finish_mission, 0),
            (set_trigger_result, 1),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (eq, "$talk_context", 19),
        (neg|main_hero_fallen, 0),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 10),
        (all_enemies_defeated),
    ],
    [
        (call_script, "script_deduct_casualties_from_garrison"),
        (try_for_agents, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (troop_slot_ge, ":var_1", slot_troop_mission_participation, 2),
            (try_begin),
                (agent_is_alive, ":var_0"),
                (troop_set_slot, ":var_1", slot_troop_mission_participation, 4),
            (else_try),
                (troop_set_slot, ":var_1", slot_troop_mission_participation, 5),
            (try_end),
        (try_end),
        (jump_to_menu, "mnu_sneak_into_town_caught_ran_away"),
        (mission_enable_talk),
        (finish_mission, 0),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"training_ground_trainer_talk", 0, -1, 
"Training.",
[(0, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_horse, 0, 1, []),
(1, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_horse, 0, 1, []),
(2, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_horse, 0, 1, []),
(3, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_horse, 0, 1, []),
(4, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_horse, 0, 1, []),
(5, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_horse, 0, 1, []),
(6, mtef_scene_source|mtef_team_0, 0, 0, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (0.000000, 1.000000, 2.000000, 
    [
        (neg|ge, "$trainer_help_message", 2),
    ],
    [
        (try_begin),
            (eq, "$trainer_help_message", 0),
        (else_try),
        (try_end),
        (val_add, "$trainer_help_message", 1),
    ]),


],),

(
"training_ground_trainer_training", 1, -1, 
"You_will_fight_a_match_in_the_arena.",
[(16, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_shield, itm_practice_sword, itm_practice_boots]),
(17, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff, itm_practice_boots]),
(18, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff, itm_practice_boots]),
(19, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_boots]),
(20, mtef_visitor_source, 0, 0, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (question_box, "str_give_up_fight"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (set_jump_mission, "mt_training_ground_trainer_talk"),
        (modify_visitors_at_site, "$g_training_ground_melee_training_scene"),
        (reset_visitors),
        (set_jump_entry, 5),
        (jump_to_scene, "$g_training_ground_melee_training_scene"),
    ]),

    (1.000000, 3.000000, ti_once, 
    [
        (main_hero_fallen, 0),
    ],
    [
        (set_jump_mission, "mt_training_ground_trainer_talk"),
        (modify_visitors_at_site, "$g_training_ground_melee_training_scene"),
        (reset_visitors),
        (set_jump_entry, 5),
        (jump_to_scene, "$g_training_ground_melee_training_scene"),
    ]),

    (1.000000, 3.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 1),
        (num_active_teams_le, 1),
        (neg|main_hero_fallen),
        (assign, "$training_fight_won", 1),
    ],
    [
        (set_jump_mission, "mt_training_ground_trainer_talk"),
        (modify_visitors_at_site, "$g_training_ground_melee_training_scene"),
        (reset_visitors),
        (set_jump_entry, 5),
        (jump_to_scene, "$g_training_ground_melee_training_scene"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_arena"),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"training_ground_training", 1, -1, 
"Training.",
[(0, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(1, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(2, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(3, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(4, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(8, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(10, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(11, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(12, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(13, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(14, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(15, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_last_destroyed_gourds", 0),
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (question_box, "str_give_up_fight"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$g_training_ground_training_success_ratio", 0),
        (try_begin),
            (eq, "$g_encountered_party", "p_castle_noldor"),
            (change_screen_map),
        (else_try),
            (jump_to_menu, "mnu_training_ground_training_result"),
        (try_end),
        (finish_mission),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (try_begin),
            (eq, "$g_mt_mode", 2),
            (set_fixed_point_multiplier, 100),
            (entry_point_get_position, pos1, 0),
            (init_position, pos2),
            (position_set_y, pos2, "$g_training_ground_ranged_distance"),
            (position_transform_position_to_parent, pos3, pos1, pos2),
            (copy_position, pos1, pos3),
            (assign, ":var_0", 10),
            (assign, ":var_1", 0),
            (try_for_range, ":var_2", 0, ":var_0"),
                (store_sub, ":var_3", ":var_2", ":var_1"),
                (scene_prop_get_instance, ":var_4", "spr_gourd", ":var_3"),
                (copy_position, pos2, pos1),
                (init_position, pos0),
                (store_random_in_range, ":var_5", 0, 360),
                (position_rotate_z, pos2, ":var_5"),
                (store_random_in_range, ":var_5", 50, 600),
                (position_move_x, pos2, ":var_5"),
                (store_random_in_range, ":var_5", 0, 360),
                (position_transform_position_to_local, pos3, pos1, pos2),
                (position_rotate_z, pos0, ":var_5"),
                (position_transform_position_to_parent, pos4, pos0, pos3),
                (position_transform_position_to_parent, pos2, pos1, pos4),
                (position_set_z_to_ground_level, pos2),
                (position_move_z, pos2, 150),
                (assign, ":var_6", 1),
                (try_for_range, ":var_7", 0, 10),
                    (eq, ":var_6", 1),
                    (neg|eq, ":var_3", ":var_7"),
                    (scene_prop_get_instance, ":var_8", "spr_gourd", ":var_7"),
                    (prop_instance_get_position, pos3, ":var_8"),
                    (get_distance_between_positions, ":var_9", pos2, pos3),
                    (neg|ge, ":var_9", 100),
                    (assign, ":var_6", 0),
                (try_end),
                (try_begin),
                    (eq, ":var_6", 0),
                    (val_add, ":var_0", 1),
                    (val_add, ":var_1", 1),
                (else_try),
                    (prop_instance_set_position, ":var_4", pos2),
                    (prop_instance_animate_to_position, ":var_4", 2, 1),
                    (scene_prop_get_instance, ":var_8", "spr_gourd_spike", ":var_3"),
                    (position_move_z, pos2, -150),
                    (prop_instance_set_position, ":var_8", pos2),
                    (prop_instance_animate_to_position, ":var_8", 2, 1),
                (try_end),
            (try_end),
        (else_try),
            (eq, "$g_mt_mode", 3),
            (assign, ":var_10", 0),
            (try_for_range, ":var_2", 0, 100),
                (scene_prop_get_instance, ":var_4", "spr_gourd", ":var_2"),
                (scene_prop_get_instance, ":var_8", "spr_gourd_spike", ":var_2"),
                (ge, ":var_4", 0),
                (ge, ":var_8", 0),
                (val_add, ":var_10", 1),
                (prop_instance_get_position, pos0, ":var_8"),
                (position_move_z, pos0, 150),
                (prop_instance_set_position, ":var_4", pos0),
                (prop_instance_animate_to_position, ":var_4", 0, 1),
            (try_end),
            (store_sub, ":var_0", ":var_10", "$g_training_ground_training_num_gourds_to_destroy"),
            (try_for_range, ":var_2", 0, ":var_0"),
                (store_random_in_range, ":var_11", 0, ":var_10"),
                (scene_prop_get_instance, ":var_4", "spr_gourd", ":var_11"),
                (prop_instance_get_position, pos0, ":var_4"),
                (position_get_z, ":var_12", pos0),
                (try_begin),
                    (neg|ge, ":var_12", -50000),
                (else_try),
                    (position_set_z, pos0, -100000),
                    (prop_instance_set_position, ":var_4", pos0),
                    (prop_instance_animate_to_position, ":var_4", 0, 1),
                    (scene_prop_get_instance, ":var_8", "spr_gourd_spike", ":var_11"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (prop_instance_animate_to_position, ":var_8", 0, 1),
                (try_end),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (1.000000, 3.000000, ti_once, 
    [
        (eq, "$g_mt_mode", 1),
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (neg|main_hero_fallen),
            (assign, "$g_training_ground_training_success_ratio", 100),
        (else_try),
            (assign, ":var_0", 0),
            (try_for_agents, ":var_1"),
                (agent_is_alive, ":var_1"),
                (agent_is_human, ":var_1"),
                (agent_get_team, ":var_2", ":var_1"),
                (eq, ":var_2", 1),
                (val_add, ":var_0", 1),
            (try_end),
            (store_sub, ":var_3", "$g_training_ground_training_num_enemies", ":var_0"),
            (store_mul, "$g_training_ground_training_success_ratio", ":var_3", 100),
            (val_div, "$g_training_ground_training_success_ratio", "$g_training_ground_training_num_enemies"),
        (try_end),
        (try_begin),
            (eq, "$g_encountered_party", "p_castle_noldor"),
            (change_screen_map),
        (else_try),
            (jump_to_menu, "mnu_training_ground_training_result"),
        (try_end),
        (finish_mission),
    ]),

    (1.000000, 3.000000, ti_once, 
    [
        (eq, "$g_mt_mode", 2),
        (get_player_agent_no, ":var_0"),
        (agent_get_ammo, ":var_1", ":var_0"),
        (store_mission_timer_a, ":var_2"),
        (this_or_next|main_hero_fallen),
        (this_or_next|eq, ":var_1", 0),
        (gt, ":var_2", 116),
    ],
    [
        (store_mul, "$g_training_ground_training_success_ratio", "$scene_num_total_gourds_destroyed", 10),
        (jump_to_menu, "mnu_training_ground_training_result"),
        (finish_mission),
    ]),

    (1.000000, 3.000000, ti_once, 
    [
        (eq, "$g_mt_mode", 3),
        (get_player_agent_no, ":var_0"),
        (agent_get_horse, ":var_1", ":var_0"),
        (store_mission_timer_a, ":var_2"),
        (this_or_next|neg|ge, ":var_1", 0),
        (this_or_next|main_hero_fallen),
        (this_or_next|ge, "$scene_num_total_gourds_destroyed", "$g_training_ground_training_num_gourds_to_destroy"),
        (gt, ":var_2", 120),
    ],
    [
        (store_mul, "$g_training_ground_training_success_ratio", "$scene_num_total_gourds_destroyed", 100),
        (val_div, "$g_training_ground_training_success_ratio", "$g_training_ground_training_num_gourds_to_destroy"),
        (jump_to_menu, "mnu_training_ground_training_result"),
        (finish_mission),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (gt, "$g_last_destroyed_gourds", 0),
        (try_begin),
            (eq, "$g_mt_mode", 2),
            (entry_point_get_position, pos1, 0),
            (position_move_y, pos1, 100, 0),
            (get_player_agent_no, ":var_0"),
            (agent_get_position, pos2, ":var_0"),
            (try_begin),
                (position_is_behind_position, pos2, pos1),
                (val_add, "$scene_num_total_gourds_destroyed", "$g_last_destroyed_gourds"),
            (else_try),
                (display_message, "@You must stay behind the line on the ground! Point is not counted."),
            (try_end),
        (else_try),
            (val_add, "$scene_num_total_gourds_destroyed", "$g_last_destroyed_gourds"),
        (try_end),
        (assign, "$g_last_destroyed_gourds", 0),
    ],
    [
    ]),


],),

(
"sneak_caught_fight", 2, -1, 
"You_must_fight_your_way_out!",
[(0, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(1, mtef_scene_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_pilgrim_hood, itm_pilgrim_disguise, itm_lute, itm_dagger, itm_throwing_daggers]),
(2, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(3, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(4, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(5, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(6, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(7, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(8, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(9, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(10, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(11, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(12, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(13, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(14, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(15, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(16, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(17, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(18, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(19, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(20, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(21, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(22, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(23, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(24, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(25, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(26, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(27, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(28, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(29, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(30, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(31, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(34, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(35, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(36, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(37, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(38, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(39, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(40, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(64, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, ":var_0", 5),
        (try_begin),
            (party_get_slot, ":var_1", "$current_town", slot_town_last_nearby_fire_time),
            (store_current_hours, ":var_2"),
            (store_add, ":var_3", ":var_1", 4),
            (is_between, ":var_2", ":var_3", ":var_1"),
            (assign, ":var_0", 2),
        (else_try),
            (this_or_next|eq, "$talk_context", 19),
            (eq, "$talk_context", 18),
            (assign, ":var_0", 4),
        (try_end),
        (try_begin),
            (this_or_next|eq, "$talk_context", 19),
            (eq, "$talk_context", 18),
            (entry_point_get_position, pos0, 7),
        (else_try),
            (party_slot_eq, "$current_town", slot_party_type, 3),
            (entry_point_get_position, pos0, 0),
        (else_try),
            (entry_point_get_position, pos0, 1),
        (try_end),
        (assign, ":var_4", -1),
        (assign, ":var_5", -1),
        (try_for_range, ":var_6", 0, ":var_0"),
            (assign, ":var_7", 100000),
            (try_for_range, ":var_8", 2, 64),
                (neg|eq, ":var_5", ":var_8"),
                (entry_point_get_position, pos1, ":var_8"),
                (get_distance_between_positions, ":var_9", pos0, pos1),
                (neg|ge, ":var_9", ":var_7"),
                (gt, ":var_9", ":var_4"),
                (assign, ":var_7", ":var_9"),
                (assign, ":var_10", ":var_8"),
            (try_end),
            (store_faction_of_party, ":var_11", "$current_town"),
            (try_begin),
                (this_or_next|eq, ":var_6", 0),
                (eq, ":var_6", 2),
                (faction_get_slot, ":var_12", ":var_11", slot_faction_quick_battle_tier_2_infantry),
            (else_try),
                (faction_get_slot, ":var_12", ":var_11", slot_faction_quick_battle_tier_2_infantry),
            (try_end),
            (assign, ":var_5", ":var_10"),
            (assign, ":var_4", ":var_7"),
            (add_visitors_to_current_scene, ":var_10", ":var_12", 1, 0),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (question_box, "str_do_you_wish_to_surrender"),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (jump_to_menu, "mnu_captivity_start_castle_defeat"),
        (finish_mission, 0),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (play_sound, "snd_sneak_town_halt"),
        (call_script, "script_music_set_situation_with_culture", 1024),
    ]),

    (0.000000, 3.000000, 0.000000, 
    [
        (main_hero_fallen, 0),
    ],
    [
        (jump_to_menu, "mnu_captivity_start_castle_defeat"),
        (finish_mission, 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos0, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (eq, ":var_2", 1),
            (agent_get_position, pos1, ":var_1"),
            (get_distance_between_positions, ":var_3", pos0, pos1),
            (try_begin),
                (neg|gt, ":var_3", 800),
                (agent_clear_scripted_mode, ":var_1"),
            (else_try),
                (agent_set_scripted_destination, ":var_1", pos0, 0),
            (try_end),
        (try_end),
    ]),

    (5.000000, 1.000000, ti_once, 
    [
        (num_active_teams_le, 1),
        (neg|main_hero_fallen),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 5),
    ],
    [
        (assign, "$auto_menu", -1),
        (jump_to_menu, "mnu_sneak_into_town_caught_dispersed_guards"),
        (finish_mission, 1),
    ]),

    (ti_on_leave_area, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$auto_menu", -1),
        (jump_to_menu, "mnu_sneak_into_town_caught_ran_away"),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_arena"),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"ai_training", 0, -1, 
"You_start_training.",
[(0, 0, 0, 16, 30, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (finish_mission, 0),
    ]),


],),

(
"camera_test", 0, -1, 
"camera_Test.",
[],
[
    (1.000000, 0.000000, 0.000000, 
    [
        (mission_cam_set_mode, 1),
        (entry_point_get_position, pos3, 3),
        (mission_cam_set_position, pos3),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (finish_mission, 0),
    ]),


],),

(
"ai_training_with_formations", 0, -1, 
"You_start_training.",
[(0, 0, 0, 16, 30, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (finish_mission, 0),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (mission_disable_talk),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_use_baggage_for_inventory"),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_set_disciplined_faction"),
        (try_begin),
            (eq, "$g_option_formations", 1),
            (assign, "$gk_order", 0),
            (assign, "$gk_order_hold_over_there", 0),
            (assign, "$autorotate_at_player", 1),
            (assign, "$infantry_formation_type", 1),
            (assign, "$archer_formation_type", 1),
            (assign, "$cavalry_formation_type", 4),
            (assign, "$infantry_space", 2),
            (assign, "$archer_space", 2),
            (assign, "$cavalry_space", 0),
            (assign, "$fclock", 1),
            (assign, "$yield", 0),
        (try_end),
    ]),

    (0.100000, 0.000000, ti_once, 
    [
        (eq, "$g_option_formations", 1),
    ],
    [
        (assign, "$yield", 0),
        (call_script, "script_get_yield"),
        (val_div, "$yield", 4),
        (val_add, "$yield", 25),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
        (this_or_next|eq, "$g_option_formations", 0),
        (eq, "$g_disciplined_faction", 0),
    ],
    [
        (get_player_agent_no, "$fplayer_agent_no"),
        (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (set_show_messages, 0),
        (team_give_order, "$fplayer_team_no", 9, 0),
        (position_move_x, pos1, 1500),
        (position_move_y, pos1, 500),
        (team_set_order_position, "$fplayer_team_no", 2, pos1),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (position_move_x, pos1, -1500),
        (position_move_y, pos1, 500),
        (team_set_order_position, "$fplayer_team_no", 0, pos1),
        (agent_get_position, pos1, "$fplayer_agent_no"),
        (position_move_y, pos1, 2000),
        (team_set_order_position, "$fplayer_team_no", 1, pos1),
        (set_show_messages, 1),
    ]),

    (0.000000, 0.400000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (get_player_agent_no, "$fplayer_agent_no"),
            (agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
            (assign, ":var_0", 0),
            (assign, ":var_1", 0),
            (assign, ":var_2", 0),
            (assign, ":var_3", 0),
            (assign, "$team0_size", 0),
            (assign, "$team1_size", 0),
            (assign, "$team2_size", 0),
            (assign, "$team3_size", 0),
            (try_for_agents, ":var_4"),
                (agent_is_human, ":var_4"),
                (agent_get_team, ":var_5", ":var_4"),
                (agent_get_troop_id, ":var_6", ":var_4"),
                (store_troop_faction, ":var_7", ":var_6"),
                (try_begin),
                    (eq, ":var_5", 0),
                    (val_add, ":var_0", ":var_7"),
                    (val_add, "$team0_size", 1),
                (else_try),
                    (eq, ":var_5", 1),
                    (val_add, ":var_1", ":var_7"),
                    (val_add, "$team1_size", 1),
                (else_try),
                    (eq, ":var_5", 2),
                    (val_add, ":var_2", ":var_7"),
                    (val_add, "$team2_size", 1),
                (else_try),
                    (eq, ":var_5", 3),
                    (val_add, ":var_3", ":var_7"),
                    (val_add, "$team3_size", 1),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team0_size", 0),
                (team_get_leader, ":var_8", 0),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team0_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team0_faction", ":var_0", 10),
                    (val_div, "$team0_faction", "$team0_size"),
                    (val_add, "$team0_faction", 5),
                    (val_div, "$team0_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team1_size", 0),
                (team_get_leader, ":var_8", 1),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team1_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team1_faction", ":var_1", 10),
                    (val_div, "$team1_faction", "$team1_size"),
                    (val_add, "$team1_faction", 5),
                    (val_div, "$team1_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team2_size", 0),
                (team_get_leader, ":var_8", 2),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team2_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team2_faction", ":var_2", 10),
                    (val_div, "$team2_faction", "$team2_size"),
                    (val_add, "$team2_faction", 5),
                    (val_div, "$team2_faction", 10),
                (try_end),
            (try_end),
            (try_begin),
                (gt, "$team3_size", 0),
                (team_get_leader, ":var_8", 3),
                (try_begin),
                    (ge, ":var_8", 0),
                    (agent_get_troop_id, ":var_9", ":var_8"),
                    (store_troop_faction, "$team3_faction", ":var_9"),
                (else_try),
                    (store_mul, "$team3_faction", ":var_3", 10),
                    (val_div, "$team3_faction", "$team3_size"),
                    (val_add, "$team3_faction", 5),
                    (val_div, "$team3_faction", 10),
                (try_end),
            (try_end),
            (display_message, "@Forming ranks."),
            (call_script, "script_get_default_formation", "$fplayer_team_no"),
            (assign, "$infantry_formation_type", reg0),
            (call_script, "script_player_attempt_formation", 0, "$infantry_formation_type"),
            (call_script, "script_player_attempt_formation", 2, 4),
            (call_script, "script_player_attempt_formation", 1, 1),
            (set_show_messages, 0),
            (try_for_range, reg0, 3, 9),
                (team_give_order, "$fplayer_team_no", reg0, 0),
            (try_end),
            (try_for_range, reg0, 0, "$infantry_space"),
                (team_give_order, "$fplayer_team_no", 0, 8),
            (try_end),
            (try_for_range, reg0, 0, "$archer_space"),
                (team_give_order, "$fplayer_team_no", 1, 8),
            (try_end),
            (try_for_range, reg0, 0, "$cavalry_space"),
                (team_give_order, "$fplayer_team_no", 2, 8),
            (try_end),
            (set_show_messages, 1),
        (try_end),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_j),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_ranks", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 2),
        (call_script, "script_player_attempt_formation", 1, 2),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_k),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_shield", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 3),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_l),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_wedge", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 4),
        (call_script, "script_player_attempt_formation", 2, 4),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_semicolon),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_formation_square", pos19),
        (try_end),
        (call_script, "script_player_attempt_formation", 0, 5),
    ]),

    (0.000000, 0.000000, 1.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_u),
    ],
    [
        (call_script, "script_player_order_formations", 2),
    ]),

    (0.000000, 0.300000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_1),
    ],
    [
        (eq, "$gk_order", 23),
        (game_key_is_down, gk_order_1),
        (assign, "$gk_order_hold_over_there", 1),
        (assign, "$gk_order", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_1),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 23),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_hold", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 0),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 24),
                (try_begin),
                    (store_random_in_range, ":var_2", 1, 101),
                    (neg|gt, ":var_2", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_advance", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 5),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_2),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 24),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_follow", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 1),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 24),
                (try_begin),
                    (store_random_in_range, ":var_2", 1, 101),
                    (neg|gt, ":var_2", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_fallback", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 6),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_3),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 0),
            (assign, "$gk_order", 25),
        (else_try),
            (try_begin),
                (eq, "$gk_order", 23),
                (try_begin),
                    (store_random_in_range, ":var_0", 1, 101),
                    (neg|gt, ":var_0", "$yield"),
                    (get_player_agent_no, ":var_1"),
                    (agent_get_position, pos19, ":var_1"),
                    (play_sound_at_position, "snd_th3_order_charge", pos19),
                (try_end),
                (call_script, "script_player_order_formations", 2),
            (else_try),
                (eq, "$gk_order", 24),
                (call_script, "script_player_order_formations", 8),
                (assign, "$gk_order", 0),
            (else_try),
                (eq, "$gk_order", 25),
                (assign, "$gk_order", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_4),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 23),
            (call_script, "script_player_order_formations", 11),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 24),
            (call_script, "script_player_order_formations", 7),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 25),
            (assign, "$gk_order", 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_5),
    ],
    [
        (try_begin),
            (eq, "$gk_order", 23),
            (try_begin),
                (store_random_in_range, ":var_0", 1, 101),
                (neg|gt, ":var_0", "$yield"),
                (get_player_agent_no, ":var_1"),
                (agent_get_position, pos19, ":var_1"),
                (play_sound_at_position, "snd_th3_order_retreat", pos19),
            (try_end),
            (call_script, "script_player_order_formations", 14),
            (assign, "$gk_order", 0),
        (else_try),
            (eq, "$gk_order", 24),
            (assign, "$gk_order", 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (game_key_clicked, gk_order_6),
    ],
    [
        (eq, "$gk_order", 24),
        (try_begin),
            (class_is_listening_order, "$fplayer_team_no", 2),
            (call_script, "script_formation_end", "$fplayer_team_no", 2),
        (try_end),
        (call_script, "script_player_order_formations", 4),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_1),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (play_sound, "snd_th3_address_infantry"),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_2),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_archers", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_3),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_cavalry", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (key_clicked, key_0),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos19, ":var_1"),
            (play_sound_at_position, "snd_th3_address_everyone", pos19),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (this_or_next|key_clicked, key_1),
        (this_or_next|key_clicked, key_2),
        (this_or_next|key_clicked, key_3),
        (this_or_next|key_clicked, key_4),
        (this_or_next|key_clicked, key_5),
        (this_or_next|key_clicked, key_6),
        (this_or_next|key_clicked, key_7),
        (this_or_next|key_clicked, key_8),
        (this_or_next|key_clicked, key_9),
        (this_or_next|key_clicked, key_0),
        (key_clicked, key_escape),
    ],
    [
        (assign, "$gk_order", 0),
    ]),

    (0.500000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$gk_order_hold_over_there", 1),
        (neg|game_key_is_down, gk_order_1),
    ],
    [
        (try_begin),
            (store_random_in_range, ":var_0", 1, 101),
            (neg|gt, ":var_0", "$yield"),
            (play_sound, "snd_th3_order_hold"),
        (try_end),
        (call_script, "script_team_get_average_position_of_enemies_augmented", 60, "$fplayer_team_no", 9),
        (assign, ":var_1", 0),
        (try_for_range, reg0, 0, 9),
            (class_is_listening_order, "$fplayer_team_no", reg0),
            (val_add, ":var_1", 1),
        (try_end),
        (agent_get_position, pos22, "$fplayer_agent_no"),
        (try_begin),
            (neg|eq, "$infantry_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 0),
            (team_get_order_position, pos2, "$fplayer_team_no", 0),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 0, "$infantry_space", "$infantry_formation_type"),
                (try_end),
            (else_try),
                (assign, ":var_2", 0),
                (try_for_agents, reg0),
                    (call_script, "script_cf_valid_formation_member", "$fplayer_team_no", 0, "$fplayer_agent_no", reg0),
                    (val_add, ":var_2", 1),
                (try_end),
                (call_script, "script_get_centering_amount", "$infantry_formation_type", ":var_2", "$infantry_space"),
                (position_move_x, pos2, reg0),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 0, 1),
                (call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
            (try_end),
            (assign, "$infantry_formation_move_order", 0),
        (try_end),
        (try_begin),
            (neg|eq, "$cavalry_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 2),
            (team_get_order_position, pos2, "$fplayer_team_no", 2),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 2, "$cavalry_space", "$cavalry_formation_type"),
                (try_end),
            (else_try),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 2, 1),
                (call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
            (try_end),
            (assign, "$cavalry_formation_move_order", 0),
        (try_end),
        (try_begin),
            (neg|eq, "$archer_formation_type", 0),
            (class_is_listening_order, "$fplayer_team_no", 1),
            (team_get_order_position, pos2, "$fplayer_team_no", 1),
            (call_script, "script_point_y_toward_position", 2, 60),
            (try_begin),
                (gt, ":var_1", 1),
                (agent_set_position, "$fplayer_agent_no", pos2),
                (try_begin),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 1, "$archer_space", "$archer_formation_type"),
                (try_end),
            (else_try),
                (assign, ":var_2", 0),
                (try_for_agents, reg0),
                    (call_script, "script_cf_valid_formation_member", "$fplayer_team_no", 1, "$fplayer_agent_no", reg0),
                    (val_add, ":var_2", 1),
                (try_end),
                (call_script, "script_get_centering_amount", 1, ":var_2", "$archer_space"),
                (val_mul, reg0, -1),
                (position_move_x, pos2, reg0),
                (copy_position, pos1, pos2),
                (call_script, "script_set_formation_position", "$fplayer_team_no", 1, 1),
                (call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space", "$archer_formation_type"),
            (try_end),
            (assign, "$archer_formation_move_order", 0),
        (try_end),
        (agent_set_position, "$fplayer_agent_no", pos22),
        (assign, "$gk_order_hold_over_there", 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (neg|key_is_down, key_j),
        (neg|key_is_down, key_k),
        (neg|key_is_down, key_l),
        (neg|key_is_down, key_semicolon),
        (neg|key_is_down, key_u),
        (neg|game_key_is_down, gk_order_1),
        (neg|game_key_is_down, gk_order_2),
        (neg|game_key_is_down, gk_order_3),
        (neg|game_key_is_down, gk_order_4),
        (neg|game_key_is_down, gk_order_5),
        (neg|game_key_is_down, gk_order_6),
    ],
    [
        (set_fixed_point_multiplier, 100),
        (store_mod, ":var_0", "$fclock", 5),
        (call_script, "script_team_get_average_position_of_enemies_augmented", 60, "$fplayer_team_no", 9),
        (try_begin),
            (eq, reg0, 0),
            (neg|eq, "$g_encountered_party", -1),
            (call_script, "script_formation_end", "$fplayer_team_no", 9),
        (else_try),
            (assign, "$autorotate_at_player", 0),
            (try_begin),
                (neg|eq, "$infantry_formation_type", 0),
                (try_begin),
                    (eq, "$infantry_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 0, "$infantry_space", "$infantry_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 0),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 0),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 0, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, "$cavalry_formation_type", 0),
                (try_begin),
                    (eq, "$cavalry_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 2, "$cavalry_space", "$cavalry_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 2),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 2),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 2, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, "$archer_formation_type", 0),
                (try_begin),
                    (eq, "$archer_formation_move_order", 1),
                    (call_script, "script_cf_formation", "$fplayer_team_no", 1, "$archer_space", "$archer_formation_type"),
                (else_try),
                    (eq, ":var_0", 0),
                    (call_script, "script_get_formation_position", 0, "$fplayer_team_no", 1),
                    (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", "$fplayer_team_no", 1),
                    (call_script, "script_point_y_toward_position", 1, 60),
                    (position_copy_rotation, pos0, pos1),
                    (call_script, "script_set_formation_position", "$fplayer_team_no", 1, 0),
                    (copy_position, pos1, pos0),
                    (call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space", "$archer_formation_type"),
                (try_end),
            (try_end),
            (assign, "$autorotate_at_player", 1),
        (try_end),
        (val_add, "$fclock", 1),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (assign, "$cur_casualties", 0),
            (assign, "$prev_casualties", 0),
            (assign, "$prev_casualties2", 0),
            (assign, "$ranged_clock", 1),
            (assign, "$battle_phase", 1),
            (assign, "$clock_reset", 0),
            (assign, "$charge_activated", 0),
            (assign, "$charge_ongoing", 0),
            (assign, "$inf_charge_activated", 0),
            (assign, "$inf_charge_ongoing", 0),
            (assign, "$arc_charge_activated", 0),
            (assign, "$att_reinforcements_arrived", 0),
            (assign, "$def_reinforcements_arrived", 0),
            (assign, "$att_reinforcements_needed", 0),
            (assign, "$def_reinforcements_needed", 0),
            (assign, "$disengage", 0),
            (assign, "$patrol_mode", 0),
            (store_random_in_range, "$rand0", -1000, 1000),
            (store_random_in_range, "$rand2", 800, 1501),
            (store_random_in_range, "$rand1", 0, 501),
            (store_random_in_range, "$rand3", 2000, 3001),
            (store_random_in_range, "$rand4", 1000, 3001),
            (store_random_in_range, "$rand5", -1000, 0),
            (store_random_in_range, "$rand6", 4000, 5001),
            (store_random_in_range, "$rand7", 49, 56),
            (store_random_in_range, "$rand8", -100, 101),
            (assign, "$team0_default_formation", 1),
            (assign, "$team1_default_formation", 1),
            (assign, "$team2_default_formation", 1),
            (assign, "$team3_default_formation", 1),
            (init_position, pos56),
            (init_position, pos57),
            (init_position, pos58),
            (init_position, pos59),
            (assign, "$team0_reinforcement_stage", 0),
            (assign, "$team1_reinforcement_stage", 0),
            (init_position, pos17),
            (init_position, pos18),
        (try_end),
    ]),

    (0.000000, 0.500000, ti_once, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_option_formations", 1),
            (eq, "$g_disciplined_faction", 1),
            (try_for_agents, ":var_0"),
                (agent_set_slot, ":var_0", slot_agent_is_running_away, 0),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (call_script, "script_store_battlegroup_data"),
            (call_script, "script_battlegroup_get_position", 12, 0, 9),
            (call_script, "script_battlegroup_get_position", 13, 1, 9),
            (call_script, "script_battlegroup_get_position", 14, 2, 9),
            (call_script, "script_battlegroup_get_position", 16, 3, 9),
            (call_script, "script_field_tactics", 1),
        (try_end),
    ]),

    (60.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$g_disciplined_faction", 1),
    ],
    [
        (store_random_in_range, "$rand0", -1000, 1000),
        (store_random_in_range, "$rand2", 800, 1501),
        (store_random_in_range, "$rand1", -1000, 1000),
        (store_random_in_range, "$rand3", 2000, 3001),
        (store_random_in_range, "$rand4", 1000, 3001),
        (store_random_in_range, "$rand5", -1000, 0),
        (store_random_in_range, "$rand6", 4000, 5001),
        (store_random_in_range, "$rand7", 45, 56),
        (store_random_in_range, "$rand8", -100, 101),
    ]),

    (1.000000, 0.900000, 0.000000, 
    [
        (eq, "$g_option_formations", 1),
        (eq, "$g_disciplined_faction", 1),
    ],
    [
        (try_begin),
            (assign, "$prev_casualties2", "$cur_casualties"),
            (call_script, "script_cf_count_casualties"),
            (assign, "$cur_casualties", reg0),
            (assign, "$battle_phase", 3),
        (try_end),
        (set_fixed_point_multiplier, 100),
        (call_script, "script_store_battlegroup_data"),
        (try_begin),
            (eq, "$battle_phase", 3),
            (eq, "$clock_reset", 0),
            (call_script, "script_field_tactics", 1),
            (assign, "$ranged_clock", 0),
            (assign, "$clock_reset", 1),
        (else_try),
            (ge, "$battle_phase", 2),
            (store_mod, reg0, "$ranged_clock", 5),
            (eq, reg0, 0),
            (call_script, "script_field_tactics", 1),
            (assign, "$team0_reinforcement_stage", "$defender_reinforcement_stage"),
            (assign, "$team1_reinforcement_stage", "$attacker_reinforcement_stage"),
        (else_try),
            (call_script, "script_field_tactics", 0),
        (try_end),
        (try_begin),
            (eq, "$battle_phase", 1),
            (assign, ":var_0", 0),
            (try_for_range, ":var_1", 0, 4),
                (neg|eq, ":var_1", "$fplayer_team_no"),
                (call_script, "script_battlegroup_get_size", ":var_1", 9),
                (gt, reg0, 0),
                (call_script, "script_battlegroup_get_position", 1, ":var_1", 1),
                (team_get_order_position, pos0, ":var_1", 1),
                (get_distance_between_positions, reg0, pos0, pos1),
                (gt, reg0, 500),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 0),
            (assign, "$battle_phase", 2),
        (try_end),
        (val_add, "$ranged_clock", 1),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_v),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (set_show_messages, 0),
        (try_for_range, ":var_2", 0, 9),
            (class_is_listening_order, ":var_1", ":var_2"),
            (team_give_order, ":var_1", ":var_2", 0),
        (try_end),
        (get_player_agent_no, ":var_3"),
        (try_for_agents, ":var_4"),
            (agent_is_alive, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_get_team, ":var_5", ":var_4"),
            (eq, ":var_5", ":var_1"),
            (agent_get_division, ":var_2", ":var_4"),
            (class_is_listening_order, ":var_1", ":var_2"),
            (agent_get_horse, ":var_6", ":var_4"),
            (neg|gt, ":var_6", 0),
            (neg|eq, ":var_4", ":var_3"),
            (agent_set_is_alarmed, ":var_4", 0),
            (agent_get_slot, ":var_7", ":var_4", 250),
            (ge, ":var_7", 10),
            (try_begin),
                (agent_get_animation, ":var_8", ":var_4"),
                (assign, ":var_9", "anim_spearwall_hold"),
                (neg|eq, ":var_8", ":var_9"),
                (agent_set_animation, ":var_4", ":var_9"),
                (agent_get_position, pos1, ":var_4"),
                (agent_set_scripted_destination, ":var_4", pos1),
                (set_fixed_point_multiplier, 100),
                (agent_get_look_position, pos1, ":var_4"),
                (position_get_x, ":var_10", pos1),
                (position_get_y, ":var_11", pos1),
                (agent_set_slot, ":var_4", slot_agent_target_x_pos, ":var_10"),
                (agent_set_slot, ":var_4", slot_agent_target_y_pos, ":var_11"),
            (try_end),
        (try_end),
        (set_show_messages, 1),
    ]),

    (0.100000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (agent_get_horse, ":var_2", ":var_0"),
        (try_for_agents, ":var_3"),
            (agent_is_alive, ":var_3"),
            (agent_is_human, ":var_3"),
            (agent_slot_eq, ":var_3", slot_agent_is_running_away, 0),
            (agent_get_horse, ":var_4", ":var_3"),
            (neg|gt, ":var_4", 0),
            (agent_get_slot, ":var_5", ":var_3", 250),
            (agent_get_simple_behavior, ":var_6", ":var_3"),
            (agent_get_team, ":var_7", ":var_3"),
            (agent_get_class, ":var_8", ":var_3"),
            (team_get_movement_order, ":var_9", ":var_7", ":var_8"),
            (assign, ":var_10", 0),
            (agent_get_animation, ":var_11", ":var_3"),
            (try_begin),
                (neg|eq, ":var_7", ":var_1"),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (this_or_next|eq, ":var_9", 0),
                (eq, ":var_9", 11),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
                (neg|eq, ":var_3", ":var_0"),
                (assign, ":var_12", "anim_spearwall_hold"),
                (eq, ":var_11", ":var_12"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
                (assign, ":var_10", 0),
            (try_end),
            (try_begin),
                (eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (assign, ":var_10", 1),
            (try_end),
            (eq, ":var_10", 1),
            (agent_get_wielded_item, ":var_13", ":var_3", 0),
            (try_begin),
                (neg|ge, ":var_13", 0),
                (agent_get_wielded_item, ":var_13", ":var_3", 1),
            (try_end),
            (ge, ":var_13", 0),
            (item_get_type, ":var_14", ":var_13"),
            (eq, ":var_14", 4),
            (item_get_slot, ":var_15", ":var_13", 17),
            (try_begin),
                (eq, ":var_15", 0),
                (assign, ":var_15", 145),
            (try_end),
            (val_add, ":var_15", 10),
            (try_begin),
                (agent_get_speed, pos0, ":var_3"),
                (position_get_y, ":var_16", pos0),
                (position_get_x, ":var_17", pos0),
                (val_max, ":var_16", ":var_17"),
                (eq, ":var_16", 0),
                (agent_get_troop_id, ":var_18", ":var_3"),
                (store_proficiency_level, ":var_19", ":var_18", wpt_polearm),
                (store_character_level, ":var_20", ":var_18"),
                (ge, ":var_20", 12),
                (ge, ":var_19", 120),
                (item_get_slot, ":var_21", ":var_13", 200),
                (store_and, ":var_22", ":var_21", 256),
                (gt, ":var_22", 0),
                (assign, ":var_10", 1),
                (agent_get_wielded_item, ":var_23", ":var_3", 1),
                (try_begin),
                    (gt, ":var_23", 0),
                    (item_get_type, ":var_24", ":var_23"),
                    (eq, ":var_24", 7),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_10", 1),
                (try_begin),
                    (neg|ge, ":var_5", 50),
                    (val_add, ":var_5", 1),
                    (agent_set_slot, ":var_3", 250, ":var_5"),
                (try_end),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
            (try_end),
            (this_or_next|eq, ":var_3", ":var_0"),
            (ge, ":var_5", 20),
            (try_begin),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_get_position, pos1, ":var_3"),
                (agent_set_scripted_destination, ":var_3", pos1),
                (agent_set_is_alarmed, ":var_3", 0),
                (agent_get_slot, ":var_25", ":var_3", slot_agent_target_x_pos),
                (agent_get_slot, ":var_26", ":var_3", slot_agent_target_y_pos),
                (init_position, pos2),
                (position_set_x, pos2, ":var_25"),
                (position_set_y, pos2, ":var_26"),
                (agent_set_look_target_position, ":var_3", pos2),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (assign, ":var_27", -1),
            (assign, ":var_28", -1),
            (agent_get_position, pos1, ":var_3"),
            (try_for_agents, ":var_29"),
                (agent_is_alive, ":var_29"),
                (neg|agent_is_human, ":var_29"),
                (agent_get_rider, ":var_30", ":var_29"),
                (ge, ":var_30", 0),
                (agent_get_team, ":var_31", ":var_30"),
                (teams_are_enemies, ":var_7", ":var_31"),
                (agent_get_position, pos2, ":var_29"),
                (get_distance_between_positions, ":var_32", pos1, pos2),
                (neg|ge, ":var_32", ":var_15"),
                (neg|position_is_behind_position, 2, 1),
                (agent_get_speed, pos4, ":var_29"),
                (position_get_x, ":var_33", pos4),
                (position_get_y, ":var_34", pos4),
                (this_or_next|gt, ":var_33", 350),
                (gt, ":var_34", 350),
                (get_angle_between_positions, ":var_35", pos1, pos2),
                (val_abs, ":var_35"),
                (convert_from_fixed_point, ":var_35"),
                (is_between, ":var_35", 150, 181),
                (assign, ":var_27", ":var_29"),
                (assign, ":var_28", ":var_30"),
            (try_end),
            (try_begin),
                (eq, ":var_27", -1),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (store_sub, ":var_32", ":var_15", 20),
                (call_script, "script_agent_get_closest_enemy", ":var_3", ":var_32"),
                (ge, reg0, 1),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_set_slot, ":var_3", 250, 0),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
            (try_end),
            (gt, ":var_27", -1),
            (val_mul, ":var_33", ":var_33"),
            (val_mul, ":var_34", ":var_34"),
            (store_add, ":var_36", ":var_33", ":var_34"),
            (store_sqrt, ":var_36", ":var_36"),
            (val_div, ":var_36", 100),
            (store_mul, ":var_37", ":var_36", 4),
            (try_begin),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
            (try_end),
            (agent_clear_scripted_mode, ":var_3"),
            (agent_set_slot, ":var_3", 250, 0),
            (agent_play_sound, ":var_27", "snd_metal_hit_high_armor_high_damage"),
            (store_agent_hit_points, ":var_38", ":var_27", 1),
            (store_sub, ":var_39", ":var_38", ":var_37"),
            (val_max, ":var_39", 0),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27", ":var_37"),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27"),
            (store_agent_hit_points, ":var_39", ":var_27", 1),
            (store_agent_hit_points, ":var_40", ":var_28", 1),
            (try_begin),
                (gt, ":var_39", 0),
                (agent_set_animation, ":var_27", "anim_horse_rear"),
            (else_try),
                (neg|gt, ":var_39", 0),
                (agent_deliver_damage_to_agent, ":var_27", ":var_28"),
            (try_end),
            (store_agent_hit_points, ":var_41", ":var_28", 1),
            (try_begin),
                (eq, ":var_27", ":var_2"),
                (val_sub, ":var_38", ":var_39"),
                (assign, reg1, ":var_38"),
                (display_message, "@Your horse received {reg1} damage from a braced spear!", 0xFF4040),
                (try_begin),
                    (val_sub, ":var_40", ":var_41"),
                    (gt, ":var_40", 0),
                    (assign, reg2, ":var_40"),
                    (display_message, "@You received {reg2} damage from a braced spear!", 0xFF4040),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),
        (this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),
        (game_key_clicked, gk_sheath_weapon),
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_animation, ":var_1", ":var_0"),
        (eq, ":var_1", "anim_spearwall_hold"),
        (agent_set_animation, ":var_0", "anim_spearwall_hold_recoil"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_b),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (try_begin),
            (neg|ge, ":var_1", 0),
            (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (try_end),
        (ge, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 4),
        (item_get_slot, ":var_3", ":var_1", 200),
        (store_and, ":var_4", ":var_3", 256),
        (gt, ":var_4", 0),
        (assign, ":var_5", 1),
        (agent_get_wielded_item, ":var_6", ":var_0", 1),
        (try_begin),
            (gt, ":var_6", 0),
            (item_get_type, ":var_7", ":var_6"),
            (eq, ":var_7", 7),
            (assign, ":var_5", 0),
        (try_end),
        (eq, ":var_5", 1),
        (agent_get_horse, ":var_8", ":var_0"),
        (neg|gt, ":var_8", 0),
        (agent_get_animation, ":var_9", ":var_0"),
        (neg|eq, ":var_9", "anim_spearwall_hold"),
        (neg|eq, ":var_9", "anim_spearwall_hold_recoil"),
        (str_store_item_name, s1, ":var_1"),
        (display_message, "@Bracing {s1} for charge.", 0x6495ED),
        (agent_set_animation, ":var_0", "anim_spearwall_hold"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"arena_melee_fight", 1, -1, 
"You_enter_a_melee_fight_in_the_arena.",
[(0, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_red, itm_red_tourney_helmet]),
(1, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_arena_tunic_red]),
(2, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_red, itm_red_tourney_helmet]),
(3, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_red, itm_red_tourney_helmet]),
(4, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_dagger, itm_arena_tunic_red]),
(5, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_arena_tunic_red]),
(6, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_red]),
(7, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_red, itm_red_tourney_helmet]),
(8, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_dagger, itm_arena_tunic_blue]),
(9, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_blue, itm_blue_tourney_helmet]),
(10, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_arena_tunic_blue]),
(11, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_arena_tunic_blue, itm_blue_tourney_helmet]),
(12, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_blue]),
(13, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_blue, itm_blue_tourney_helmet]),
(14, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_arena_tunic_blue]),
(15, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_arena_tunic_blue]),
(16, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_green, itm_green_tourney_helmet]),
(17, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_arena_tunic_green, itm_green_tourney_helmet]),
(18, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_green, itm_green_tourney_helmet]),
(19, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_green, itm_green_tourney_helmet]),
(20, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_dagger, itm_arena_tunic_green, itm_green_tourney_helmet]),
(21, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_arena_tunic_green]),
(22, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_green]),
(23, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_green, itm_green_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(25, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(26, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(27, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(28, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_dagger, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(29, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_arena_tunic_yellow]),
(30, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_yellow]),
(31, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(32, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword]),
(33, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(34, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield]),
(35, mtef_visitor_source|mtef_team_0|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(36, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_dagger]),
(37, mtef_visitor_source|mtef_team_0|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield]),
(38, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword]),
(39, mtef_visitor_source|mtef_team_0|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_staff]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_dagger, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_arena_tunic_yellow]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_heavy_practice_sword, itm_practice_horse, itm_arena_tunic_yellow]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_lance, itm_practice_shield, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(24, mtef_visitor_source|mtef_team_3, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_bow, itm_practice_arrows, itm_practice_horse, itm_arena_tunic_yellow, itm_gold_tourney_helmet]),
(50, mtef_scene_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(51, mtef_visitor_source, af_override_weapons|af_override_head|af_override_horse, 0, 1, []),
(52, mtef_scene_source, af_override_horse, 0, 1, []),
(53, mtef_scene_source, af_override_horse, 0, 1, []),
(54, mtef_scene_source, af_override_horse, 0, 1, []),
(55, mtef_scene_source, af_override_horse, 0, 1, []),
(56, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_padded_cloth, itm_segmented_helmet]),
(57, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_practice_sword, itm_practice_shield, itm_padded_cloth, itm_segmented_helmet]),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
        (assign, "$g_arena_training_num_agents_spawned", 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_arena"),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_mt_mode", 2),
            (set_trigger_result, 1),
        (else_try),
            (question_box, "str_give_up_fight"),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (try_begin),
            (eq, "$g_mt_mode", 3),
            (call_script, "script_end_tournament_fight", 0),
        (else_try),
            (eq, "$g_mt_mode", 1),
            (get_player_agent_no, ":var_1"),
            (agent_get_kill_count, "$g_arena_training_kills", ":var_1", 1),
        (try_end),
        (finish_mission, 0),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_mt_mode", 2),
        (call_script, "script_music_set_situation_with_culture", 65536),
        (store_current_scene, reg1),
        (scene_set_slot, reg1, 0, 1),
        (mission_enable_talk),
        (get_player_agent_no, ":var_0"),
        (assign, ":var_1", 0),
        (try_for_agents, ":var_2"),
            (neg|eq, ":var_2", ":var_0"),
            (agent_get_troop_id, ":var_3", ":var_2"),
            (is_between, ":var_3", "trp_novice_fighter", "trp_ramun_the_slave_trader"),
            (eq, ":var_1", 0),
            (agent_set_team, ":var_2", 1),
            (assign, ":var_1", 1),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_mt_mode", 3),
        (play_sound, "snd_arena_ambiance", 2),
        (call_script, "script_music_set_situation_with_culture", 134217728),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (eq, "$g_mt_mode", 3),
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (neg|main_hero_fallen),
            (call_script, "script_end_tournament_fight", 1),
            (call_script, "script_play_victorious_sound"),
            (finish_mission),
        (else_try),
            (call_script, "script_end_tournament_fight", 0),
            (finish_mission),
        (try_end),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_mt_mode", 1),
        (start_presentation, "prsnt_arena_training"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_mt_mode", 1),
        (assign, "$g_arena_training_max_opponents", 40),
        (assign, "$g_arena_training_num_agents_spawned", 0),
        (assign, "$g_arena_training_kills", 0),
        (assign, "$g_arena_training_won", 0),
        (call_script, "script_music_set_situation_with_culture", 131072),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (eq, "$g_mt_mode", 1),
        (store_mission_timer_a, ":var_0"),
        (gt, ":var_0", 3),
        (assign, ":var_1", 0),
        (try_begin),
            (ge, "$g_arena_training_num_agents_spawned", "$g_arena_training_max_opponents"),
            (num_active_teams_le, 1),
            (assign, ":var_1", 1),
        (try_end),
        (this_or_next|eq, ":var_1", 1),
        (main_hero_fallen),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_kill_count, "$g_arena_training_kills", ":var_0", 1),
        (assign, "$g_arena_training_won", 0),
        (try_begin),
            (neg|main_hero_fallen),
            (assign, "$g_arena_training_won", 1),
        (try_end),
        (assign, "$g_mt_mode", 2),
        (set_jump_mission, "mt_arena_melee_fight"),
        (party_get_slot, ":var_1", "$current_town", slot_town_arena),
        (modify_visitors_at_site, ":var_1"),
        (reset_visitors),
        (set_visitor, 35, "trp_veteran_fighter"),
        (set_visitor, 36, "trp_hired_blade"),
        (set_jump_entry, 50),
        (jump_to_scene, ":var_1"),
    ]),

    (0.200000, 0.000000, 0.000000, 
    [
        (eq, "$g_mt_mode", 1),
        (assign, ":var_0", 0),
        (try_for_agents, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_is_alive, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (is_between, ":var_2", 0, 7),
            (val_add, ":var_0", 1),
        (try_end),
        (neg|ge, ":var_0", 7),
        (neg|main_hero_fallen),
        (store_mission_timer_a, ":var_3"),
        (this_or_next|ge, ":var_3", "$g_arena_training_next_spawn_time"),
        (this_or_next|neg|ge, "$g_arena_training_num_agents_spawned", 6),
        (num_active_teams_le, 1),
        (neg|ge, "$g_arena_training_num_agents_spawned", "$g_arena_training_max_opponents"),
    ],
    [
        (assign, ":var_0", "$g_arena_training_num_agents_spawned"),
        (store_div, ":var_0", "$g_arena_training_num_agents_spawned", 6),
        (assign, ":var_1", "$g_arena_training_num_agents_spawned"),
        (val_mod, ":var_1", 6),
        (val_add, ":var_0", ":var_1"),
        (val_min, ":var_0", 9),
        (val_add, ":var_0", "trp_arena_training_fighter_1"),
        (assign, ":var_2", 10000),
        (get_player_agent_no, ":var_3"),
        (agent_get_position, pos5, ":var_3"),
        (try_for_range, ":var_4", 0, ":var_2"),
            (store_random_in_range, ":var_5", 32, 40),
            (neg|eq, ":var_5", "$g_player_entry_point"),
            (entry_point_get_position, pos1, ":var_5"),
            (get_distance_between_positions, ":var_6", pos5, pos1),
            (gt, ":var_6", 1200),
            (assign, ":var_2", 0),
        (try_end),
        (add_visitors_to_current_scene, ":var_5", ":var_0", 1),
        (store_add, ":var_7", "$g_arena_training_num_agents_spawned", 1),
        (store_mission_timer_a, ":var_8"),
        (store_add, "$g_arena_training_next_spawn_time", ":var_8", 14),
        (store_div, ":var_9", ":var_7", 3),
        (val_sub, "$g_arena_training_next_spawn_time", ":var_9"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_mt_mode", 1),
    ],
    [
        (assign, ":var_0", 6),
        (val_max, ":var_0", 1),
        (get_player_agent_no, ":var_1"),
        (try_for_agents, ":var_2"),
            (agent_is_human, ":var_2"),
            (agent_is_alive, ":var_2"),
            (agent_slot_eq, ":var_2", slot_agent_arena_team_set, 0),
            (agent_get_team, ":var_3", ":var_2"),
            (is_between, ":var_3", 0, 7),
            (try_begin),
                (eq, ":var_2", ":var_1"),
                (agent_set_team, ":var_2", 6),
            (else_try),
                (store_random_in_range, ":var_4", 0, ":var_0"),
                (try_for_range, ":var_5", 0, 6),
                    (troop_set_slot, "trp_temp_array_a", ":var_5", 0),
                (try_end),
                (try_for_agents, ":var_6"),
                    (agent_is_human, ":var_6"),
                    (agent_is_alive, ":var_6"),
                    (neg|eq, ":var_2", ":var_1"),
                    (agent_slot_eq, ":var_6", slot_agent_arena_team_set, 1),
                    (agent_get_team, ":var_7", ":var_6"),
                    (troop_get_slot, ":var_8", "trp_temp_array_a", ":var_7"),
                    (val_add, ":var_8", 1),
                    (troop_set_slot, "trp_temp_array_a", ":var_7", ":var_8"),
                (try_end),
                (assign, ":var_9", 0),
                (troop_get_slot, ":var_10", "trp_temp_array_a", slot_troop_relations_begin),
                (try_for_range, ":var_5", 1, 6),
                    (troop_slot_ge, "trp_temp_array_a", ":var_5", ":var_10"),
                    (troop_get_slot, ":var_10", "trp_temp_array_a", ":var_5"),
                    (assign, ":var_9", ":var_5"),
                (try_end),
                (store_random_in_range, ":var_11", 5, 100),
                (try_begin),
                    (neg|ge, ":var_11", "$g_arena_training_num_agents_spawned"),
                    (assign, ":var_4", ":var_9"),
                (try_end),
                (agent_set_team, ":var_2", ":var_4"),
            (try_end),
            (agent_set_slot, ":var_2", slot_agent_arena_team_set, 1),
            (try_begin),
                (neg|eq, ":var_2", ":var_1"),
                (val_add, "$g_arena_training_num_agents_spawned", 1),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"arena_challenge_fight", 17, -1, 
"You_enter_a_melee_fight_in_the_arena.",
[(56, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_0|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cannot_leave_now"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 131072),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (check_quest_active, "qst_duel_for_lady"),
            (quest_slot_eq, "qst_duel_for_lady", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_duel_for_lady"),
        (else_try),
            (check_quest_active, "qst_duel_for_lady"),
            (quest_slot_eq, "qst_duel_for_lady", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_duel_for_lady"),
        (else_try),
            (main_hero_fallen),
            (check_quest_active, "qst_duel_courtship_rival"),
            (quest_slot_eq, "qst_duel_courtship_rival", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_duel_courtship_rival"),
        (else_try),
            (check_quest_active, "qst_duel_courtship_rival"),
            (quest_slot_eq, "qst_duel_courtship_rival", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_duel_courtship_rival"),
        (else_try),
            (main_hero_fallen),
            (check_quest_active, "qst_duel_avenge_insult"),
            (quest_slot_eq, "qst_duel_avenge_insult", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_duel_avenge_insult"),
        (else_try),
            (check_quest_active, "qst_duel_avenge_insult"),
            (quest_slot_eq, "qst_duel_avenge_insult", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_duel_avenge_insult"),
        (else_try),
            (main_hero_fallen),
            (check_quest_active, "qst_denounce_lord"),
            (quest_slot_eq, "qst_denounce_lord", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_denounce_lord"),
        (else_try),
            (check_quest_active, "qst_denounce_lord"),
            (quest_slot_eq, "qst_denounce_lord", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_denounce_lord"),
        (else_try),
            (quest_get_slot, ":var_0", "qst_denounce_lord", 2),
            (str_store_troop_name, s4, ":var_0"),
        (try_end),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"arena_heroic_challenge_fight", 17, -1, 
"You_enter_a_fight_in_the_arena.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0|mtef_team_1, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0|mtef_team_1, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "@Cannot leave now."),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 131072),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (assign, "$g_order_challenge_won", -1),
            (display_log_message, "@ You've lost the challenge!!!"),
        (else_try),
            (assign, "$g_order_challenge_won", 1),
            (display_log_message, "@ You've won the challenge!!!"),
        (try_end),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"duel_with_lord", 17, -1, 
"You_enter_a_melee_fight_in_the_arena.",
[(0, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_sword_medieval_a, itm_arena_tunic_blue]),
(16, mtef_visitor_source|mtef_team_1, af_override_weapons|af_override_head|af_override_body|af_override_gloves|af_override_horse, 16, 1, [itm_sword_medieval_a, itm_arena_tunic_blue]),
],
[
    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cannot_leave_now"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 131072),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (check_quest_active, "qst_duel_for_lady"),
            (quest_slot_eq, "qst_duel_for_lady", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_duel_for_lady"),
        (else_try),
            (check_quest_active, "qst_duel_for_lady"),
            (quest_slot_eq, "qst_duel_for_lady", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_duel_for_lady"),
        (else_try),
            (main_hero_fallen),
            (check_quest_active, "qst_duel_courtship_rival"),
            (quest_slot_eq, "qst_duel_courtship_rival", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_duel_courtship_rival"),
        (else_try),
            (check_quest_active, "qst_duel_courtship_rival"),
            (quest_slot_eq, "qst_duel_courtship_rival", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_duel_courtship_rival"),
        (else_try),
            (main_hero_fallen),
            (check_quest_active, "qst_duel_avenge_insult"),
            (quest_slot_eq, "qst_duel_avenge_insult", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_duel_avenge_insult"),
        (else_try),
            (check_quest_active, "qst_duel_avenge_insult"),
            (quest_slot_eq, "qst_duel_avenge_insult", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_duel_avenge_insult"),
        (else_try),
            (main_hero_fallen),
            (check_quest_active, "qst_denounce_lord"),
            (quest_slot_eq, "qst_denounce_lord", 2, "$g_duel_troop"),
            (call_script, "script_fail_quest", "qst_denounce_lord"),
        (else_try),
            (check_quest_active, "qst_denounce_lord"),
            (quest_slot_eq, "qst_denounce_lord", 2, "$g_duel_troop"),
            (call_script, "script_succeed_quest", "qst_denounce_lord"),
        (else_try),
            (quest_get_slot, ":var_0", "qst_denounce_lord", 2),
            (str_store_troop_name, s4, ":var_0"),
        (try_end),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"wedding", 0, -1, 
"Wedding",
[(0, mtef_visitor_source, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_tabard, itm_ankle_boots]),
(1, mtef_visitor_source, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_bride_dress, itm_bride_crown, itm_bride_shoes]),
(2, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(3, mtef_visitor_source, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_courtly_outfit, itm_blue_hose]),
(4, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(5, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(6, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(7, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(8, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(9, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(10, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(11, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(12, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(13, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(14, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(15, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(16, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(17, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(18, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(19, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(20, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(21, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(22, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(23, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(24, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(25, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(26, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(27, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(28, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(29, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(30, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
(31, mtef_visitor_source, af_override_weapons|af_override_horse|af_require_civilian, 0, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (show_object_details_overlay, 1),
        (finish_mission, 0),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (show_object_details_overlay, 1),
        (finish_mission, 0),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_wedding_state", 0),
        (play_track, "track_wedding", 2),
        (show_object_details_overlay, 0),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (troop_get_type, ":var_2", ":var_1"),
        (set_fixed_point_multiplier, 100),
        (try_begin),
            (eq, ":var_1", "$g_wedding_bishop_troop"),
        (else_try),
            (eq, ":var_1", "$g_wedding_bride_troop"),
            (agent_set_no_dynamics, ":var_0", 1),
            (init_position, pos1),
            (position_set_z, pos1, -1000),
            (agent_set_position, ":var_0", pos1),
        (else_try),
            (eq, ":var_1", "$g_wedding_brides_dad_troop"),
            (agent_set_no_dynamics, ":var_0", 1),
            (init_position, pos1),
            (position_set_z, pos1, -1000),
            (agent_set_position, ":var_0", pos1),
        (else_try),
            (eq, ":var_1", "$g_wedding_groom_troop"),
            (agent_set_no_dynamics, ":var_0", 1),
            (init_position, pos1),
            (position_move_x, pos1, 175),
            (position_move_z, pos1, 10),
            (position_rotate_z, pos1, 180),
            (agent_set_position, ":var_0", pos1),
            (agent_set_animation, ":var_0", "anim_wedding_groom_wait"),
        (else_try),
            (try_begin),
                (eq, ":var_2", 0),
                (store_random_in_range, ":var_3", 0, 3),
                (try_begin),
                    (eq, ":var_3", 0),
                    (agent_set_slot, ":var_0", slot_agent_cur_animation, "anim_wedding_guest_notr"),
                    (agent_set_animation, ":var_0", "anim_wedding_guest_notr"),
                (else_try),
                    (agent_set_slot, ":var_0", slot_agent_cur_animation, "anim_wedding_guest"),
                    (agent_set_animation, ":var_0", "anim_wedding_guest"),
                (try_end),
            (else_try),
                (agent_set_slot, ":var_0", slot_agent_cur_animation, "anim_wedding_guest_woman"),
                (agent_set_animation, ":var_0", "anim_wedding_guest_woman"),
            (try_end),
            (store_random_in_range, ":var_4", 0, 100),
            (agent_set_animation_progress, ":var_0", ":var_4"),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (store_mission_timer_a, ":var_0"),
        (set_fixed_point_multiplier, 100),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (try_begin),
                (eq, ":var_2", "$g_wedding_groom_troop"),
            (else_try),
                (eq, ":var_2", "$g_wedding_bride_troop"),
            (else_try),
                (eq, ":var_2", "$g_wedding_brides_dad_troop"),
            (else_try),
                (eq, ":var_2", "$g_wedding_bishop_troop"),
            (else_try),
                (agent_get_slot, ":var_3", ":var_1", slot_agent_cur_animation),
                (agent_set_animation, ":var_1", ":var_3"),
            (try_end),
        (try_end),
        (try_begin),
            (eq, "$g_wedding_state", 0),
            (mission_cam_set_mode, 1, 0, 0),
            (init_position, pos1),
            (position_rotate_z, pos1, 180),
            (position_rotate_x, pos1, 5),
            (position_set_x, pos1, -500),
            (position_set_y, pos1, 1000),
            (position_set_z, pos1, 600),
            (mission_cam_set_position, pos1),
            (init_position, pos1),
            (position_rotate_z, pos1, 180),
            (position_rotate_x, pos1, -15),
            (position_set_x, pos1, -500),
            (position_set_y, pos1, 1000),
            (position_set_z, pos1, 600),
            (mission_cam_animate_to_position, pos1, 4000, 0),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 1),
            (ge, ":var_0", 4),
            (init_position, pos1),
            (position_rotate_z, pos1, 90),
            (position_rotate_x, pos1, -10),
            (position_set_x, pos1, -580),
            (position_set_y, pos1, 700),
            (position_set_z, pos1, 200),
            (mission_cam_set_position, pos1),
            (init_position, pos1),
            (position_rotate_z, pos1, 150),
            (position_rotate_x, pos1, -10),
            (position_set_x, pos1, -580),
            (position_set_y, pos1, 100),
            (position_set_z, pos1, 200),
            (mission_cam_animate_to_position, pos1, 6000, 1),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 2),
            (ge, ":var_0", 9),
            (mission_cam_animate_to_screen_color, 4278190080, 1000),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 3),
            (ge, ":var_0", 10),
            (init_position, pos1),
            (position_move_x, pos1, 175),
            (position_move_z, pos1, 10),
            (position_rotate_z, pos1, 180),
            (try_for_agents, ":var_1"),
                (agent_get_troop_id, ":var_4", ":var_1"),
                (try_begin),
                    (eq, ":var_4", "$g_wedding_bride_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_bride_stairs"),
                (else_try),
                    (eq, ":var_4", "$g_wedding_brides_dad_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_dad_stairs"),
                (try_end),
            (try_end),
            (init_position, pos1),
            (position_rotate_z, pos1, -90),
            (position_set_x, pos1, 300),
            (position_set_y, pos1, 950),
            (position_set_z, pos1, 420),
            (mission_cam_set_position, pos1),
            (position_set_x, pos1, 175),
            (position_set_y, pos1, 950),
            (position_set_z, pos1, 320),
            (mission_cam_animate_to_position, pos1, 4000, 0),
            (mission_cam_animate_to_screen_color, 0, 500),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 4),
            (ge, ":var_0", 14),
            (init_position, pos1),
            (position_rotate_z, pos1, -60),
            (position_rotate_x, pos1, 10),
            (position_set_x, pos1, -400),
            (position_set_y, pos1, 200),
            (position_set_z, pos1, 115),
            (mission_cam_set_position, pos1),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 5),
            (ge, ":var_0", 20),
            (init_position, pos1),
            (position_move_x, pos1, 175),
            (position_move_z, pos1, 10),
            (position_rotate_z, pos1, 180),
            (try_for_agents, ":var_1"),
                (agent_get_troop_id, ":var_4", ":var_1"),
                (try_begin),
                    (eq, ":var_4", "$g_wedding_bride_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_bride_walk"),
                (else_try),
                    (eq, ":var_4", "$g_wedding_brides_dad_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_dad_walk"),
                (try_end),
            (try_end),
            (init_position, pos1),
            (position_rotate_z, pos1, -140),
            (position_rotate_x, pos1, -15),
            (position_set_x, pos1, -625),
            (position_set_y, pos1, -530),
            (position_set_z, pos1, 180),
            (mission_cam_set_position, pos1),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 6),
            (ge, ":var_0", 22),
            (init_position, pos1),
            (position_rotate_z, pos1, 45),
            (position_rotate_x, pos1, -10),
            (position_set_x, pos1, -260),
            (position_set_y, pos1, 120),
            (position_set_z, pos1, 275),
            (mission_cam_set_position, pos1),
            (position_rotate_z, pos1, 10),
            (mission_cam_animate_to_position, pos1, 2000, 0),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 7),
            (ge, ":var_0", 24),
            (init_position, pos1),
            (position_move_x, pos1, 175),
            (position_move_z, pos1, 10),
            (position_rotate_z, pos1, 180),
            (try_for_agents, ":var_1"),
                (agent_get_troop_id, ":var_4", ":var_1"),
                (try_begin),
                    (eq, ":var_4", "$g_wedding_bride_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_bride_last"),
                (else_try),
                    (eq, ":var_4", "$g_wedding_brides_dad_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_dad_last"),
                (else_try),
                    (eq, ":var_4", "$g_wedding_groom_troop"),
                    (agent_set_position, ":var_1", pos1),
                    (agent_set_animation, ":var_1", "anim_wedding_groom_last"),
                (try_end),
            (try_end),
            (init_position, pos1),
            (position_rotate_z, pos1, -45),
            (position_rotate_x, pos1, -10),
            (position_set_x, pos1, -900),
            (position_set_y, pos1, -850),
            (position_set_z, pos1, 230),
            (mission_cam_set_position, pos1),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 8),
            (ge, ":var_0", 31),
            (init_position, pos1),
            (position_set_x, pos1, -550),
            (position_set_y, pos1, -625),
            (position_set_z, pos1, 1500),
            (particle_system_burst, "psys_wedding_rose", pos1, 750),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 9),
            (ge, ":var_0", 33),
            (init_position, pos1),
            (position_rotate_z, pos1, 180),
            (position_set_x, pos1, -536),
            (position_set_y, pos1, -415),
            (position_set_z, pos1, 135),
            (mission_cam_set_position, pos1),
            (position_rotate_z, pos1, -8),
            (position_set_z, pos1, 350),
            (position_rotate_x, pos1, 35),
            (mission_cam_animate_to_position_and_aperture, pos1, 10, 9000, 1),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 10),
            (ge, ":var_0", 41),
            (mission_cam_set_screen_color, 16777215),
            (mission_cam_animate_to_screen_color, 4294967295, 3000),
            (val_add, "$g_wedding_state", 1),
        (else_try),
            (eq, "$g_wedding_state", 11),
            (ge, ":var_0", 48),
            (show_object_details_overlay, 1),
            (finish_mission, 0),
        (try_end),
    ],
    [
    ]),


],),

(
"tutorial_training_ground", 1, -1, 
"You_enter_the_training_ground.",
[(0, mtef_visitor_source|mtef_team_0, 0, 0, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_sword]),
(33, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_sword]),
(34, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_sword]),
(35, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_sword]),
(36, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_bow, itm_practice_arrows]),
(42, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_bow, itm_practice_arrows]),
(43, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_sword]),
(62, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_sword]),
(63, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_bow, itm_practice_arrows]),
(64, mtef_visitor_source|mtef_team_0, af_override_weapons, 16, 1, [itm_practice_bow, itm_practice_arrows]),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$g_tutorial_training_ground_state", 20),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_tutorial_show_mouse_movement"),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_ai_set_always_attack_in_melee, ":var_0", 1),
        (agent_set_no_death_knock_down_only, ":var_0", 1),
        (agent_set_invulnerable_shield, ":var_0", 1),
        (agent_get_position, pos1, ":var_0"),
        (agent_set_slot, ":var_0", slot_agent_spawn_entry_point, -1),
        (get_player_agent_no, ":var_1"),
        (try_begin),
            (eq, ":var_0", ":var_1"),
            (agent_set_team, ":var_0", 7),
        (try_end),
        (try_for_range, ":var_2", 0, 64),
            (entry_point_get_position, pos2, ":var_2"),
            (get_sq_distance_between_positions, ":var_3", pos1, pos2),
            (neg|ge, ":var_3", 100),
            (agent_set_slot, ":var_0", slot_agent_spawn_entry_point, ":var_2"),
        (try_end),
        (agent_get_troop_id, ":var_4", ":var_0"),
        (try_begin),
            (eq, ":var_4", "trp_tutorial_archer_1"),
            (agent_get_position, pos1, ":var_0"),
            (agent_set_scripted_destination, ":var_0", pos1),
            (scene_prop_get_num_instances, ":var_5", "spr_archery_target_with_hit_a"),
            (assign, ":var_6", 10000000),
            (assign, ":var_7", -1),
            (try_for_range, ":var_8", 0, ":var_5"),
                (scene_prop_get_instance, ":var_9", "spr_archery_target_with_hit_a", ":var_8"),
                (prop_instance_get_position, pos2, ":var_9"),
                (get_sq_distance_between_positions, ":var_10", pos1, pos2),
                (neg|ge, ":var_10", ":var_6"),
                (assign, ":var_6", ":var_10"),
                (assign, ":var_7", ":var_9"),
            (try_end),
            (agent_set_slot, ":var_0", slot_agent_target_prop_instance, ":var_7"),
        (else_try),
            (this_or_next|eq, ":var_4", "trp_tutorial_rider_1"),
            (eq, ":var_4", "trp_tutorial_rider_2"),
            (agent_set_slot, ":var_0", slot_agent_target_entry_point, 48),
            (agent_set_slot, ":var_0", slot_agent_target_prop_instance, -1),
            (entry_point_get_position, pos1, 48),
            (agent_set_scripted_destination, ":var_0", pos1),
        (try_end),
    ]),

    (ti_on_agent_knocked_down, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (agent_get_troop_id, ":var_2", ":var_0"),
        (agent_get_troop_id, ":var_3", ":var_1"),
        (try_begin),
            (ge, "$g_tutorial_training_ground_melee_trainer_attack", 0),
        (else_try),
            (ge, "$g_tutorial_training_ground_melee_trainer_parry", 0),
            (try_begin),
                (eq, ":var_2", "trp_player"),
                (eq, ":var_3", "$g_tutorial_training_ground_melee_trainer_parry"),
                (assign, "$g_tutorial_training_ground_melee_state", 0),
                (agent_set_team, ":var_0", 0),
                (agent_set_team, ":var_1", 7),
                (tutorial_message, -1),
                (assign, "$g_tutorial_mouse_dir", -1),
                (assign, "$g_tutorial_mouse_click", -1),
                (assign, "$g_tutorial_training_ground_conversation_state", 2),
                (play_sound, "snd_tutorial_fail"),
                (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_parry"),
                (assign, "$g_tutorial_training_ground_melee_trainer_parry", -1),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (agent_set_attack_action, ":var_0", 0, 0),
                (try_end),
            (else_try),
                (eq, ":var_3", "trp_player"),
                (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_parry"),
                (agent_set_team, ":var_0", 7),
                (agent_set_team, ":var_1", 0),
                (tutorial_message, -1),
                (assign, "$g_tutorial_mouse_dir", -1),
                (assign, "$g_tutorial_mouse_click", -1),
                (assign, "$g_tutorial_training_ground_conversation_state", 3),
                (play_sound, "snd_tutorial_fail"),
                (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_parry"),
                (assign, "$g_tutorial_training_ground_melee_trainer_parry", -1),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (agent_set_attack_action, ":var_0", 0, 0),
                (try_end),
            (try_end),
        (else_try),
            (ge, "$g_tutorial_training_ground_melee_trainer_chamber", 0),
            (try_begin),
                (eq, ":var_2", "trp_player"),
                (eq, ":var_3", "$g_tutorial_training_ground_melee_trainer_chamber"),
                (assign, "$g_tutorial_training_ground_melee_state", 0),
                (agent_set_team, ":var_0", 0),
                (agent_set_team, ":var_1", 7),
                (tutorial_message, -1),
                (assign, "$g_tutorial_mouse_dir", -1),
                (assign, "$g_tutorial_mouse_click", -1),
                (assign, "$g_tutorial_training_ground_conversation_state", 7),
                (play_sound, "snd_tutorial_fail"),
                (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_chamber"),
                (assign, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (agent_set_attack_action, ":var_0", 0, 0),
                (try_end),
            (else_try),
                (eq, ":var_3", "trp_player"),
                (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_chamber"),
                (agent_set_team, ":var_0", 7),
                (agent_set_team, ":var_1", 0),
                (tutorial_message, -1),
                (assign, "$g_tutorial_mouse_dir", -1),
                (assign, "$g_tutorial_mouse_click", -1),
                (assign, "$g_tutorial_training_ground_conversation_state", 8),
                (play_sound, "snd_tutorial_fail"),
                (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_chamber"),
                (assign, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (agent_set_attack_action, ":var_0", 0, 0),
                (try_end),
            (try_end),
        (else_try),
            (ge, "$g_tutorial_training_ground_melee_trainer_combat", 0),
            (try_begin),
                (eq, ":var_2", "trp_player"),
                (eq, ":var_3", "$g_tutorial_training_ground_melee_trainer_combat"),
                (assign, "$g_tutorial_training_ground_melee_state", 0),
                (agent_set_team, ":var_0", 0),
                (agent_set_team, ":var_1", 7),
                (tutorial_message, -1),
                (assign, "$g_tutorial_training_ground_conversation_state", 4),
                (play_sound, "snd_tutorial_fail"),
                (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_combat"),
                (assign, "$g_tutorial_training_ground_melee_trainer_combat", -1),
            (else_try),
                (eq, ":var_3", "trp_player"),
                (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_combat"),
                (assign, "$g_tutorial_training_ground_melee_state", 0),
                (agent_set_team, ":var_0", 7),
                (agent_set_team, ":var_1", 0),
                (tutorial_message, -1),
                (assign, "$g_tutorial_training_ground_conversation_state", 5),
                (play_sound, "snd_tutorial_2"),
                (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_combat"),
                (assign, "$g_tutorial_training_ground_melee_trainer_combat", -1),
            (try_end),
        (else_try),
            (agent_is_human, ":var_0"),
            (assign, "$g_tutorial_training_ground_melee_last_winner", ":var_1"),
            (assign, "$g_tutorial_training_ground_melee_last_loser", ":var_0"),
            (assign, "$g_tutorial_training_ground_melee_state", 0),
            (agent_set_team, "$g_tutorial_training_ground_melee_cur_fighter_1", 7),
            (agent_set_team, "$g_tutorial_training_ground_melee_cur_fighter_2", 7),
            (agent_force_rethink, "$g_tutorial_training_ground_melee_cur_fighter_1"),
            (agent_force_rethink, "$g_tutorial_training_ground_melee_cur_fighter_2"),
        (try_end),
        (agent_set_hit_points, ":var_0", 100, 0),
        (agent_set_hit_points, ":var_1", 100, 0),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (scene_set_day_time, 13),
        (team_set_relation, 0, 1, 0),
        (team_set_relation, 0, 2, 0),
        (team_set_relation, 0, 3, 0),
        (team_set_relation, 0, 7, 0),
        (team_set_relation, 7, 1, 1),
        (team_set_relation, 7, 2, 1),
        (team_set_relation, 7, 3, 1),
        (team_set_relation, 1, 2, -1),
        (team_set_relation, 1, 3, 1),
        (team_set_relation, 2, 3, 1),
        (assign, "$g_position_to_use_for_replacing_scene_items", 8),
        (call_script, "script_replace_scene_items_with_spawn_items_before_ms"),
        (assign, "$g_tutorial_training_ground_state", 0),
        (assign, "$g_tutorial_training_ground_conversation_state", 0),
        (assign, "$g_tutorial_training_ground_melee_paused", 0),
        (assign, "$g_tutorial_training_ground_melee_state", 0),
        (assign, "$g_tutorial_training_ground_melee_next_action_time", 0),
        (assign, "$g_tutorial_training_ground_melee_last_winner", -1),
        (assign, "$g_tutorial_training_ground_melee_last_loser", -1),
        (assign, "$g_tutorial_training_ground_melee_cur_fighter_1", -1),
        (assign, "$g_tutorial_training_ground_melee_cur_fighter_2", -1),
        (assign, "$g_tutorial_training_ground_melee_trainer_attack", -1),
        (assign, "$g_tutorial_training_ground_melee_trainer_parry", -1),
        (assign, "$g_tutorial_training_ground_melee_trainer_combat", -1),
        (assign, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
        (assign, "$g_tutorial_training_ground_melee_trainer_next_action_time", 0),
        (assign, "$g_tutorial_training_ground_archer_trainer_state", 0),
        (assign, "$g_tutorial_training_ground_archer_trainer_completed_chapters", 0),
        (assign, "$g_tutorial_training_ground_horseman_trainer_state", 0),
        (assign, "$g_tutorial_training_ground_horseman_trainer_completed_chapters", 0),
        (assign, "$g_tutorial_training_ground_next_score_time", 0),
        (assign, "$g_tutorial_mouse_dir", -1),
        (assign, "$g_tutorial_mouse_click", -1),
        (assign, "$g_pointer_arrow_height_adder", -1000),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (mission_enable_talk),
        (call_script, "script_replace_scene_items_with_spawn_items_after_ms"),
        (entry_point_get_position, pos1, 59),
        (set_spawn_position, pos1),
        (spawn_horse, "itm_practice_horse", 0),
        (assign, "$g_tutorial_training_ground_intro_message_being_displayed", 1),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_bow", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_bow_2", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_arrows", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_arrows_2", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_crossbow", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_bolts", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_practice_javelin", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
        (scene_spawned_item_get_instance, ":var_0", "itm_arena_lance", 0),
        (prop_instance_get_position, pos0, ":var_0"),
        (position_move_z, pos0, -1000, 1),
        (prop_instance_set_position, ":var_0", pos0),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (tutorial_message_set_background, 1),
        (tutorial_message, "str_tutorial_training_ground_intro_message"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (store_mission_timer_a, ":var_0"),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (eq, ":var_2", "trp_tutorial_archer_1"),
            (try_begin),
                (agent_get_wielded_item, ":var_3", ":var_1", 0),
                (neg|eq, ":var_3", "itm_practice_bow"),
                (agent_set_wielded_item, ":var_1", "itm_practice_bow"),
            (else_try),
                (agent_get_slot, ":var_4", ":var_1", slot_agent_target_prop_instance),
                (prop_instance_get_position, pos1, ":var_4"),
                (position_move_z, pos1, 10),
                (agent_set_look_target_position, ":var_1", pos1),
                (try_begin),
                    (neg|agent_slot_ge, ":var_1", slot_agent_next_action_time, ":var_0"),
                    (agent_set_attack_action, ":var_1", 0),
                    (store_random_in_range, ":var_5", 3, 13),
                    (val_add, ":var_5", ":var_0"),
                    (agent_set_slot, ":var_1", slot_agent_next_action_time, ":var_5"),
                (try_end),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (set_fixed_point_multiplier, 100),
        (try_for_agents, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (this_or_next|eq, ":var_1", "trp_tutorial_rider_1"),
            (eq, ":var_1", "trp_tutorial_rider_2"),
            (agent_get_slot, ":var_2", ":var_0", slot_agent_target_entry_point),
            (entry_point_get_position, pos1, ":var_2"),
            (agent_get_position, pos2, ":var_0"),
            (get_sq_distance_between_positions, ":var_3", pos1, pos2),
            (try_begin),
                (neg|ge, ":var_3", 6400),
                (val_add, ":var_2", 1),
                (try_begin),
                    (gt, ":var_2", 57),
                    (assign, ":var_2", 48),
                (try_end),
                (agent_set_slot, ":var_0", slot_agent_target_entry_point, ":var_2"),
                (entry_point_get_position, pos1, ":var_2"),
                (agent_set_scripted_destination, ":var_0", pos1),
            (try_end),
            (try_begin),
                (eq, ":var_1", "trp_tutorial_rider_2"),
                (try_begin),
                    (agent_get_wielded_item, ":var_4", ":var_0", 0),
                    (neg|eq, ":var_4", "itm_practice_bow"),
                    (agent_set_wielded_item, ":var_0", "itm_practice_bow"),
                (else_try),
                    (scene_prop_get_num_instances, ":var_5", "spr_archery_target_with_hit_a"),
                    (assign, ":var_6", 10000000),
                    (assign, ":var_7", -1),
                    (try_for_range, ":var_8", 0, ":var_5"),
                        (scene_prop_get_instance, ":var_9", "spr_archery_target_with_hit_a", ":var_8"),
                        (neg|agent_slot_eq, ":var_0", slot_agent_target_prop_instance, ":var_9"),
                        (prop_instance_get_position, pos1, ":var_9"),
                        (position_is_behind_position, pos2, pos1),
                        (get_sq_distance_between_positions, ":var_3", pos1, pos2),
                        (neg|ge, ":var_3", ":var_6"),
                        (assign, ":var_6", ":var_3"),
                        (assign, ":var_7", ":var_9"),
                    (try_end),
                    (try_begin),
                        (neg|ge, ":var_6", 40000),
                        (prop_instance_get_position, pos1, ":var_7"),
                        (position_move_z, pos1, 10),
                        (init_position, pos3),
                        (position_set_x, pos3, -160),
                        (position_transform_position_to_parent, pos4, pos1, pos3),
                        (copy_position, pos1, pos4),
                        (agent_set_look_target_position, ":var_0", pos1),
                        (neg|ge, ":var_6", 22500),
                        (agent_set_slot, ":var_0", slot_agent_target_prop_instance, ":var_7"),
                        (agent_set_attack_action, ":var_0", 0),
                    (else_try),
                        (agent_get_slot, ":var_10", ":var_0", slot_agent_target_prop_instance),
                        (ge, ":var_10", 0),
                        (prop_instance_get_position, pos1, ":var_10"),
                        (get_sq_distance_between_positions, ":var_3", pos1, pos2),
                        (neg|ge, ":var_3", 40000),
                        (position_move_z, pos1, 10),
                        (init_position, pos3),
                        (position_set_x, pos3, -160),
                        (position_transform_position_to_parent, pos4, pos1, pos3),
                        (copy_position, pos1, pos4),
                        (agent_set_look_target_position, ":var_0", pos1),
                    (try_end),
                (try_end),
            (else_try),
                (eq, ":var_1", "trp_tutorial_rider_1"),
                (try_begin),
                    (agent_get_wielded_item, ":var_4", ":var_0", 0),
                    (neg|eq, ":var_4", "itm_practice_sword"),
                    (agent_set_wielded_item, ":var_0", "itm_practice_sword"),
                (else_try),
                    (scene_prop_get_num_instances, ":var_5", "spr_dummy_a_undestructable"),
                    (assign, ":var_6", 10000000),
                    (assign, ":var_7", -1),
                    (try_for_range, ":var_8", 0, ":var_5"),
                        (scene_prop_get_instance, ":var_9", "spr_dummy_a_undestructable", ":var_8"),
                        (neg|agent_slot_eq, ":var_0", slot_agent_target_prop_instance, ":var_9"),
                        (prop_instance_get_position, pos1, ":var_9"),
                        (get_sq_distance_between_positions, ":var_3", pos1, pos2),
                        (neg|ge, ":var_3", ":var_6"),
                        (assign, ":var_6", ":var_3"),
                        (assign, ":var_7", ":var_9"),
                    (try_end),
                    (try_begin),
                        (neg|ge, ":var_6", 10000),
                        (prop_instance_get_position, pos1, ":var_7"),
                        (position_transform_position_to_local, pos3, pos2, pos1),
                        (position_get_x, ":var_11", pos3),
                        (position_get_y, ":var_12", pos3),
                        (is_between, ":var_11", -200, 200),
                        (gt, ":var_12", -100),
                        (init_position, pos3),
                        (try_begin),
                            (neg|ge, ":var_11", 0),
                            (position_move_x, pos3, -100),
                            (position_move_z, pos3, 100),
                        (else_try),
                            (position_move_x, pos3, 100),
                            (position_move_z, pos3, 150),
                        (try_end),
                        (position_transform_position_to_parent, pos4, pos2, pos3),
                        (agent_set_look_target_position, ":var_0", pos4),
                        (try_begin),
                            (neg|ge, ":var_11", 0),
                            (agent_set_attack_action, ":var_0", 2, 1),
                        (else_try),
                            (agent_set_attack_action, ":var_0", 1, 1),
                        (try_end),
                        (this_or_next|neg|ge, ":var_6", 900),
                        (neg|ge, ":var_12", 100),
                        (agent_set_attack_action, ":var_0", 0, 0),
                        (agent_set_slot, ":var_0", slot_agent_target_prop_instance, ":var_7"),
                    (else_try),
                        (agent_get_slot, ":var_10", ":var_0", slot_agent_target_prop_instance),
                        (ge, ":var_10", 0),
                        (prop_instance_get_position, pos1, ":var_10"),
                        (get_sq_distance_between_positions, ":var_3", pos1, pos2),
                        (neg|ge, ":var_3", 10000),
                        (position_transform_position_to_local, pos3, pos2, pos1),
                        (position_get_x, ":var_11", pos3),
                        (position_get_y, ":var_12", pos3),
                        (is_between, ":var_11", -200, 200),
                        (gt, ":var_12", -100),
                        (init_position, pos3),
                        (try_begin),
                            (neg|ge, ":var_11", 0),
                            (position_move_x, pos3, -100),
                            (position_move_z, pos3, 100),
                        (else_try),
                            (position_move_x, pos3, 100),
                            (position_move_z, pos3, 150),
                        (try_end),
                        (position_transform_position_to_parent, pos4, pos2, pos3),
                        (agent_set_look_target_position, ":var_0", pos4),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (store_mission_timer_a, ":var_0"),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (eq, ":var_2", "trp_tutorial_archer_1"),
            (try_begin),
                (agent_get_wielded_item, ":var_3", ":var_1", 0),
                (neg|eq, ":var_3", "itm_practice_bow"),
                (agent_set_wielded_item, ":var_1", "itm_practice_bow"),
            (else_try),
                (agent_get_slot, ":var_4", ":var_1", slot_agent_target_prop_instance),
                (prop_instance_get_position, pos1, ":var_4"),
                (agent_set_look_target_position, ":var_1", pos1),
                (try_begin),
                    (neg|agent_slot_ge, ":var_1", slot_agent_next_action_time, ":var_0"),
                    (agent_set_attack_action, ":var_1", 0),
                    (store_random_in_range, ":var_5", 3, 13),
                    (val_add, ":var_5", ":var_0"),
                    (agent_set_slot, ":var_1", slot_agent_next_action_time, ":var_5"),
                (try_end),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_iterate_pointer_arrow"),
    ],
    [
    ]),

    (5.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (store_mission_timer_a, ":var_0"),
            (ge, ":var_0", 30),
            (eq, "$g_tutorial_training_ground_intro_message_being_displayed", 1),
            (assign, "$g_tutorial_training_ground_intro_message_being_displayed", 0),
            (tutorial_message, -1),
        (try_end),
        (get_player_agent_no, ":var_1"),
        (try_for_agents, ":var_2"),
            (agent_is_human, ":var_2"),
            (neg|eq, ":var_2", ":var_1"),
            (agent_refill_ammo, ":var_2"),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (assign, ":var_2", 0),
        (try_begin),
            (eq, ":var_1", "itm_practice_bow"),
            (agent_has_item_equipped, ":var_0", "itm_practice_arrows"),
            (agent_get_ammo, ":var_3", ":var_0", 1),
            (eq, ":var_3", 0),
            (assign, ":var_2", 1),
        (else_try),
            (eq, ":var_1", "itm_practice_bow_2"),
            (agent_has_item_equipped, ":var_0", "itm_practice_arrows_2"),
            (agent_get_ammo, ":var_3", ":var_0", 1),
            (eq, ":var_3", 0),
            (assign, ":var_2", 1),
        (else_try),
            (eq, ":var_1", "itm_practice_crossbow"),
            (agent_has_item_equipped, ":var_0", "itm_practice_bolts"),
            (agent_get_ammo, ":var_3", ":var_0", 1),
            (eq, ":var_3", 0),
            (assign, ":var_2", 1),
        (else_try),
            (eq, ":var_1", "itm_practice_javelin"),
            (agent_get_ammo, ":var_3", ":var_0", 1),
            (neg|gt, ":var_3", 1),
            (assign, ":var_2", 1),
        (try_end),
        (eq, ":var_2", 1),
        (agent_refill_ammo, ":var_0"),
        (dialog_box, "str_tutorial_training_ground_ammo_refill", "@Tutorial"),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (neg|eq, "$g_tutorial_training_ground_horseman_trainer_state", 0),
        (mission_disable_talk),
        (try_begin),
            (eq, "$g_tutorial_training_ground_horseman_trainer_state", 1),
            (assign, "$g_tutorial_training_ground_current_score", 0),
            (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
        (else_try),
            (eq, "$g_tutorial_training_ground_horseman_trainer_state", 2),
            (try_begin),
                (try_begin),
                    (ge, "$g_tutorial_training_ground_horseman_trainer_item_1", 0),
                    (scene_spawned_item_get_instance, ":var_1", "$g_tutorial_training_ground_horseman_trainer_item_1", 0),
                    (prop_instance_get_position, pos0, ":var_1"),
                    (position_move_z, pos0, 1000, 1),
                    (prop_instance_set_position, ":var_1", pos0),
                    (scene_prop_get_instance, ":var_2", "spr_pointer_arrow", 0),
                    (prop_instance_set_position, ":var_2", pos0),
                    (assign, "$g_pointer_arrow_height_adder", 200),
                    (try_begin),
                        (ge, "$g_tutorial_training_ground_horseman_trainer_item_2", 0),
                        (scene_spawned_item_get_instance, ":var_1", "$g_tutorial_training_ground_horseman_trainer_item_2", 0),
                        (prop_instance_get_position, pos0, ":var_1"),
                        (position_move_z, pos0, 1000, 1),
                        (prop_instance_set_position, ":var_1", pos0),
                    (try_end),
                (try_end),
                (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_horseman_trainer_state", 3),
            (try_begin),
                (ge, "$g_tutorial_training_ground_horseman_trainer_item_1", 0),
                (try_begin),
                    (str_store_item_name, s0, "$g_tutorial_training_ground_horseman_trainer_item_1"),
                    (tutorial_message, "str_tutorial_training_ground_horseman_text_1"),
                    (agent_has_item_equipped, ":var_0", "$g_tutorial_training_ground_horseman_trainer_item_1"),
                    (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
                    (play_sound, "snd_tutorial_1"),
                (try_end),
            (else_try),
                (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_horseman_trainer_state", 4),
            (try_begin),
                (ge, "$g_tutorial_training_ground_horseman_trainer_item_2", 0),
                (try_begin),
                    (str_store_item_name, s0, "$g_tutorial_training_ground_horseman_trainer_item_2"),
                    (tutorial_message, "str_tutorial_training_ground_horseman_text_1"),
                    (agent_has_item_equipped, ":var_0", "$g_tutorial_training_ground_horseman_trainer_item_2"),
                    (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
                    (play_sound, "snd_tutorial_1"),
                (try_end),
            (else_try),
                (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_horseman_trainer_state", 5),
            (try_begin),
                (agent_get_horse, ":var_3", ":var_0"),
                (neg|ge, ":var_3", 0),
                (tutorial_message, "str_tutorial_training_ground_horseman_text_2"),
                (try_begin),
                    (assign, ":var_4", -1),
                    (try_for_agents, ":var_5"),
                        (agent_get_item_id, ":var_6", ":var_5"),
                        (eq, ":var_6", "itm_practice_horse"),
                        (assign, ":var_4", ":var_5"),
                    (try_end),
                    (agent_get_position, pos0, ":var_4"),
                    (scene_prop_get_instance, ":var_2", "spr_pointer_arrow", 0),
                    (prop_instance_get_position, pos1, ":var_2"),
                    (set_fixed_point_multiplier, 100),
                    (position_get_x, ":var_7", pos0),
                    (position_get_x, ":var_8", pos1),
                    (position_get_y, ":var_9", pos0),
                    (position_get_y, ":var_10", pos1),
                    (this_or_next|neg|eq, ":var_7", ":var_8"),
                    (neg|eq, ":var_9", ":var_10"),
                    (prop_instance_set_position, ":var_2", pos0),
                    (assign, "$g_pointer_arrow_height_adder", 200),
                (try_end),
            (else_try),
                (val_add, "$g_tutorial_training_ground_horseman_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_horseman_trainer_state", 6),
            (try_begin),
                (eq, "$g_tutorial_training_ground_horseman_trainer_completed_chapters", 0),
                (tutorial_message, "str_tutorial_training_ground_horseman_text_3"),
            (else_try),
                (eq, "$g_tutorial_training_ground_horseman_trainer_completed_chapters", 1),
                (assign, ":var_11", "spr_dummy_a_undestructable"),
                (tutorial_message, "str_tutorial_training_ground_horseman_text_4"),
            (else_try),
                (assign, ":var_11", "spr_archery_target_with_hit_a"),
                (tutorial_message, "str_tutorial_training_ground_horseman_text_5"),
            (try_end),
            (try_begin),
                (eq, "$g_tutorial_training_ground_horseman_trainer_completed_chapters", 0),
                (store_add, ":var_12", "$g_tutorial_training_ground_current_score", 48),
                (entry_point_get_position, pos0, ":var_12"),
                (init_position, pos2),
                (position_move_y, pos2, -800),
                (position_transform_position_to_parent, pos3, pos0, pos2),
                (copy_position, pos0, pos3),
                (agent_get_position, pos2, ":var_0"),
                (try_begin),
                    (get_distance_between_positions, ":var_13", pos0, pos2),
                    (neg|ge, ":var_13", 500),
                    (val_add, "$g_tutorial_training_ground_current_score", 1),
                    (ge, "$g_tutorial_training_ground_current_score", 10),
                    (assign, "$g_pointer_arrow_height_adder", -1000),
                    (tutorial_message, "str_tutorial_training_ground_horseman_text_6", 0, 10),
                    (assign, "$g_tutorial_training_ground_horseman_trainer_state", 0),
                    (val_add, "$g_tutorial_training_ground_horseman_trainer_completed_chapters", 1),
                    (play_sound, "snd_tutorial_2"),
                (try_end),
                (try_begin),
                    (scene_prop_get_instance, ":var_2", "spr_pointer_arrow", 0),
                    (prop_instance_get_position, pos1, ":var_2"),
                    (set_fixed_point_multiplier, 1),
                    (position_get_x, ":var_7", pos0),
                    (position_get_x, ":var_8", pos1),
                    (position_get_y, ":var_9", pos0),
                    (position_get_y, ":var_10", pos1),
                    (this_or_next|neg|eq, ":var_7", ":var_8"),
                    (neg|eq, ":var_9", ":var_10"),
                    (prop_instance_set_position, ":var_2", pos0),
                    (assign, "$g_pointer_arrow_height_adder", 150),
                    (play_sound, "snd_tutorial_1"),
                (try_end),
            (else_try),
                (scene_prop_get_num_instances, ":var_14", ":var_11"),
                (try_begin),
                    (neg|ge, "$g_tutorial_training_ground_current_score", 6),
                    (assign, ":var_15", -1),
                    (store_add, ":var_16", "$g_tutorial_training_ground_current_score", 1),
                    (try_for_range, ":var_17", 0, ":var_14"),
                        (scene_prop_get_instance, ":var_18", ":var_11", ":var_17"),
                        (prop_instance_get_variation_id_2, ":var_19", ":var_18"),
                        (eq, ":var_16", ":var_19"),
                        (assign, ":var_15", ":var_18"),
                        (assign, ":var_14", 0),
                    (try_end),
                    (try_begin),
                        (prop_instance_get_position, pos0, ":var_15"),
                        (scene_prop_get_instance, ":var_2", "spr_pointer_arrow", 0),
                        (prop_instance_get_position, pos1, ":var_2"),
                        (set_fixed_point_multiplier, 1),
                        (position_get_x, ":var_7", pos0),
                        (position_get_x, ":var_8", pos1),
                        (position_get_y, ":var_9", pos0),
                        (position_get_y, ":var_10", pos1),
                        (this_or_next|neg|eq, ":var_7", ":var_8"),
                        (neg|eq, ":var_9", ":var_10"),
                        (prop_instance_set_position, ":var_2", pos0),
                        (assign, "$g_pointer_arrow_height_adder", 200),
                        (play_sound, "snd_tutorial_1"),
                    (try_end),
                (else_try),
                    (assign, "$g_pointer_arrow_height_adder", -1000),
                    (try_begin),
                        (ge, "$g_tutorial_training_ground_horseman_trainer_item_2", 0),
                        (agent_unequip_item, ":var_0", "$g_tutorial_training_ground_horseman_trainer_item_2"),
                    (try_end),
                    (agent_unequip_item, ":var_0", "$g_tutorial_training_ground_horseman_trainer_item_1"),
                    (tutorial_message, "str_tutorial_training_ground_horseman_text_6", 0, 10),
                    (assign, "$g_tutorial_training_ground_horseman_trainer_state", 0),
                    (val_add, "$g_tutorial_training_ground_horseman_trainer_completed_chapters", 1),
                    (play_sound, "snd_tutorial_2"),
                (try_end),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (neg|eq, "$g_tutorial_training_ground_archer_trainer_state", 0),
        (mission_disable_talk),
        (try_begin),
            (eq, "$g_tutorial_training_ground_archer_trainer_state", 1),
            (try_begin),
                (assign, "$g_last_destroyed_gourds", 0),
                (assign, "$g_tutorial_training_ground_current_score", 0),
                (scene_spawned_item_get_instance, ":var_1", "$g_tutorial_training_ground_archer_trainer_item_1", 0),
                (prop_instance_get_position, pos0, ":var_1"),
                (position_move_z, pos0, 1000, 1),
                (prop_instance_set_position, ":var_1", pos0),
                (scene_prop_get_instance, ":var_2", "spr_pointer_arrow", 0),
                (prop_instance_set_position, ":var_2", pos0),
                (assign, "$g_pointer_arrow_height_adder", 100),
                (try_begin),
                    (ge, "$g_tutorial_training_ground_archer_trainer_item_2", 0),
                    (scene_spawned_item_get_instance, ":var_1", "$g_tutorial_training_ground_archer_trainer_item_2", 0),
                    (prop_instance_get_position, pos0, ":var_1"),
                    (position_move_z, pos0, 1000, 1),
                    (prop_instance_set_position, ":var_1", pos0),
                (try_end),
                (val_add, "$g_tutorial_training_ground_archer_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_archer_trainer_state", 2),
            (try_begin),
                (str_store_item_name, s0, "$g_tutorial_training_ground_archer_trainer_item_1"),
                (tutorial_message, "str_tutorial_training_ground_archer_text_1"),
                (agent_has_item_equipped, ":var_0", "$g_tutorial_training_ground_archer_trainer_item_1"),
                (val_add, "$g_tutorial_training_ground_archer_trainer_state", 1),
                (play_sound, "snd_tutorial_1"),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_archer_trainer_state", 3),
            (try_begin),
                (ge, "$g_tutorial_training_ground_archer_trainer_item_2", 0),
                (try_begin),
                    (str_store_item_name, s0, "$g_tutorial_training_ground_archer_trainer_item_2"),
                    (tutorial_message, "str_tutorial_training_ground_archer_text_1"),
                    (agent_has_item_equipped, ":var_0", "$g_tutorial_training_ground_archer_trainer_item_2"),
                    (val_add, "$g_tutorial_training_ground_archer_trainer_state", 1),
                    (play_sound, "snd_tutorial_1"),
                (try_end),
            (else_try),
                (val_add, "$g_tutorial_training_ground_archer_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_archer_trainer_state", 4),
            (try_begin),
                (try_for_range, ":var_3", 0, 3),
                    (scene_prop_get_instance, ":var_4", "spr_gourd", ":var_3"),
                    (prop_instance_refill_hit_points, ":var_4"),
                    (entry_point_get_position, pos0, 45),
                    (init_position, pos1),
                    (store_sub, ":var_5", ":var_3", 1),
                    (val_mul, ":var_5", 5),
                    (position_rotate_z, pos1, ":var_5"),
                    (try_begin),
                        (ge, "$g_tutorial_training_ground_archer_trainer_item_2", 0),
                        (position_move_y, pos1, 1300),
                    (else_try),
                        (position_move_y, pos1, 800),
                        (val_mul, ":var_5", 2),
                    (try_end),
                    (position_transform_position_to_parent, pos2, pos0, pos1),
                    (position_set_z_to_ground_level, pos2),
                    (scene_prop_get_instance, ":var_6", "spr_gourd_spike", ":var_3"),
                    (prop_instance_set_position, ":var_6", pos2),
                    (position_move_z, pos2, 150, 1),
                    (prop_instance_set_position, ":var_4", pos2),
                (try_end),
                (scene_prop_get_instance, ":var_2", "spr_pointer_arrow", 0),
                (scene_prop_get_instance, ":var_6", "spr_gourd_spike", 1),
                (prop_instance_get_position, pos1, ":var_6"),
                (prop_instance_set_position, ":var_2", pos1),
                (assign, "$g_pointer_arrow_height_adder", 200),
                (tutorial_message, "str_tutorial_training_ground_archer_text_2"),
                (val_add, "$g_tutorial_training_ground_archer_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_archer_trainer_state", 5),
            (try_begin),
                (try_begin),
                    (neg|eq, "$g_tutorial_training_ground_current_score", "$g_last_destroyed_gourds"),
                    (assign, "$g_tutorial_training_ground_current_score", "$g_last_destroyed_gourds"),
                    (try_begin),
                        (neg|ge, "$g_last_destroyed_gourds", 3),
                        (play_sound, "snd_tutorial_1"),
                    (else_try),
                        (play_sound, "snd_tutorial_2"),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_archer_trainer_completed_chapters", 0),
                    (eq, "$g_last_destroyed_gourds", 0),
                    (entry_point_get_position, pos0, 45),
                    (agent_get_position, pos1, ":var_0"),
                    (neg|position_is_behind_position, 1, 0),
                    (tutorial_message, "str_tutorial_training_ground_archer_text_3"),
                (else_try),
                    (eq, "$g_tutorial_training_ground_archer_trainer_completed_chapters", 0),
                    (eq, "$g_last_destroyed_gourds", 1),
                    (tutorial_message, "str_tutorial_training_ground_archer_text_4"),
                (try_end),
                (ge, "$g_last_destroyed_gourds", 3),
                (assign, "$g_pointer_arrow_height_adder", -1000),
                (val_add, "$g_tutorial_training_ground_archer_trainer_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_archer_trainer_state", 6),
            (try_begin),
                (try_begin),
                    (ge, "$g_tutorial_training_ground_archer_trainer_item_2", 0),
                    (agent_unequip_item, ":var_0", "$g_tutorial_training_ground_archer_trainer_item_2"),
                (try_end),
                (agent_unequip_item, ":var_0", "$g_tutorial_training_ground_archer_trainer_item_1"),
                (tutorial_message, "str_tutorial_training_ground_archer_text_5", 0, 10),
                (assign, "$g_tutorial_training_ground_archer_trainer_state", 0),
                (val_add, "$g_tutorial_training_ground_archer_trainer_completed_chapters", 1),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (neg|eq, "$g_tutorial_training_ground_melee_trainer_attack", -1),
        (mission_disable_talk),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_attack"),
            (assign, ":var_3", ":var_1"),
        (try_end),
        (try_begin),
            (eq, "$g_tutorial_training_ground_melee_state", 0),
            (try_begin),
                (try_for_agents, ":var_1"),
                    (agent_get_troop_id, ":var_2", ":var_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_2"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_3"),
                    (eq, ":var_2", "trp_tutorial_fighter_4"),
                    (agent_set_team, ":var_1", 7),
                    (agent_get_slot, ":var_4", ":var_1", slot_agent_spawn_entry_point),
                    (entry_point_get_position, pos1, ":var_4"),
                    (agent_set_scripted_destination, ":var_1", pos1),
                    (agent_force_rethink, ":var_1"),
                (try_end),
                (agent_set_wielded_item, ":var_3", "itm_practice_sword"),
                (store_random_in_range, "$g_tutorial_training_ground_melee_state", 1, 5),
                (assign, "$g_tutorial_update_mouse_presentation", 1),
                (assign, "$g_tutorial_training_ground_next_score_time", 0),
            (try_end),
        (else_try),
            (gt, "$g_tutorial_training_ground_melee_state", 0),
            (try_begin),
                (agent_set_team, ":var_0", 1),
                (agent_set_team, ":var_3", 2),
                (agent_get_position, pos1, ":var_0"),
                (agent_set_scripted_destination_no_attack, ":var_3", pos1),
                (agent_get_attack_action, ":var_5", ":var_0"),
                (try_begin),
                    (eq, ":var_5", 2),
                    (agent_get_action_dir, ":var_6", ":var_0"),
                    (try_begin),
                        (eq, ":var_6", 0),
                        (agent_set_defend_action, ":var_3", 0, 1),
                    (else_try),
                        (eq, ":var_6", 3),
                        (agent_set_defend_action, ":var_3", 3, 1),
                    (else_try),
                        (eq, ":var_6", 1),
                        (agent_set_defend_action, ":var_3", 2, 1),
                    (else_try),
                        (eq, ":var_6", 2),
                        (agent_set_defend_action, ":var_3", 1, 1),
                    (try_end),
                (try_end),
                (try_begin),
                    (ge, "$g_tutorial_training_ground_current_score", 5),
                    (tutorial_message, -1),
                    (assign, "$g_tutorial_training_ground_melee_state", 0),
                    (agent_set_team, ":var_0", 0),
                    (agent_set_team, ":var_3", 7),
                    (agent_set_hit_points, ":var_0", 100, 0),
                    (agent_set_hit_points, ":var_3", 100, 0),
                    (assign, "$g_tutorial_training_ground_conversation_state", 9),
                    (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_attack"),
                    (assign, "$g_tutorial_training_ground_melee_trainer_attack", -1),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (agent_get_attack_action, ":var_5", ":var_0"),
            (eq, ":var_5", 2),
            (agent_get_action_dir, ":var_6", ":var_0"),
            (store_add, ":var_7", ":var_6", 1),
            (agent_get_wielded_item, ":var_8", ":var_0", 0),
            (call_script, "script_cf_is_melee_weapon_for_tutorial", ":var_8"),
            (store_mission_timer_a, ":var_9"),
            (gt, ":var_9", "$g_tutorial_training_ground_next_score_time"),
            (try_begin),
                (eq, ":var_7", "$g_tutorial_training_ground_melee_state"),
                (val_add, "$g_tutorial_training_ground_current_score", 1),
                (try_begin),
                    (ge, "$g_tutorial_training_ground_current_score", 5),
                    (assign, "$g_tutorial_training_ground_melee_state", 5),
                    (play_sound, "snd_tutorial_2"),
                (else_try),
                    (play_sound, "snd_tutorial_1"),
                    (assign, ":var_10", 100),
                    (try_for_range, ":var_11", 0, ":var_10"),
                        (store_random_in_range, ":var_12", 1, 5),
                        (neg|eq, ":var_12", "$g_tutorial_training_ground_melee_state"),
                        (assign, "$g_tutorial_training_ground_melee_state", ":var_12"),
                        (assign, ":var_10", 0),
                    (try_end),
                (try_end),
                (assign, "$g_tutorial_update_mouse_presentation", 1),
            (else_try),
                (val_add, "$g_tutorial_training_ground_current_score_2", 1),
                (play_sound, "snd_tutorial_fail"),
            (try_end),
            (store_add, "$g_tutorial_training_ground_next_score_time", ":var_9", 1),
        (try_end),
        (assign, reg0, "$g_tutorial_training_ground_current_score"),
        (assign, reg1, "$g_tutorial_training_ground_current_score_2"),
        (str_clear, s0),
        (assign, "$g_tutorial_mouse_dir", -1),
        (assign, "$g_tutorial_mouse_click", -1),
        (try_begin),
            (neg|eq, "$g_tutorial_training_ground_melee_state", 5),
            (store_mission_timer_a, ":var_9"),
            (this_or_next|eq, "$g_tutorial_update_mouse_presentation", 0),
            (gt, ":var_9", "$g_tutorial_training_ground_next_score_time"),
            (try_begin),
                (eq, "$g_tutorial_training_ground_melee_state", 1),
                (str_store_string, s0, "str_tutorial_training_ground_attack_training_down"),
            (else_try),
                (eq, "$g_tutorial_training_ground_melee_state", 4),
                (str_store_string, s0, "str_tutorial_training_ground_attack_training_up"),
            (else_try),
                (eq, "$g_tutorial_training_ground_melee_state", 2),
                (str_store_string, s0, "str_tutorial_training_ground_attack_training_right"),
            (else_try),
                (eq, "$g_tutorial_training_ground_melee_state", 3),
                (str_store_string, s0, "str_tutorial_training_ground_attack_training_left"),
            (try_end),
            (store_sub, "$g_tutorial_mouse_dir", "$g_tutorial_training_ground_melee_state", 1),
            (assign, "$g_tutorial_mouse_click", 0),
            (try_begin),
                (eq, "$g_tutorial_update_mouse_presentation", 1),
                (assign, "$g_tutorial_update_mouse_presentation", 0),
                (start_presentation, "prsnt_tutorial_show_mouse_movement"),
            (try_end),
        (try_end),
        (try_begin),
            (agent_get_wielded_item, ":var_8", ":var_0", 0),
            (call_script, "script_cf_is_melee_weapon_for_tutorial", ":var_8"),
            (tutorial_message, "str_tutorial_training_ground_attack_training"),
        (else_try),
            (tutorial_message, "str_tutorial_training_ground_warning_melee"),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (neg|eq, "$g_tutorial_training_ground_melee_trainer_parry", -1),
        (mission_disable_talk),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_parry"),
            (assign, ":var_3", ":var_1"),
        (try_end),
        (try_begin),
            (eq, "$g_tutorial_training_ground_melee_state", 0),
            (try_begin),
                (try_for_agents, ":var_1"),
                    (agent_get_troop_id, ":var_2", ":var_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_2"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_3"),
                    (eq, ":var_2", "trp_tutorial_fighter_4"),
                    (agent_set_team, ":var_1", 7),
                    (agent_get_slot, ":var_4", ":var_1", slot_agent_spawn_entry_point),
                    (entry_point_get_position, pos1, ":var_4"),
                    (agent_set_scripted_destination, ":var_1", pos1),
                    (agent_force_rethink, ":var_1"),
                (try_end),
                (agent_set_wielded_item, ":var_3", "itm_practice_sword"),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
                (store_mission_timer_a, "$g_tutorial_training_ground_melee_next_action_time"),
                (val_add, "$g_tutorial_training_ground_melee_next_action_time", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_melee_state", 1),
            (try_begin),
                (store_mission_timer_a, ":var_5"),
                (gt, ":var_5", "$g_tutorial_training_ground_melee_next_action_time"),
                (agent_set_team, ":var_0", 1),
                (agent_set_team, ":var_3", 2),
                (agent_get_position, pos1, ":var_0"),
                (agent_set_scripted_destination_no_attack, ":var_3", pos1),
                (agent_get_position, pos2, ":var_3"),
                (get_sq_distance_between_positions, ":var_6", pos1, pos2),
                (neg|ge, ":var_6", 400),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 0),
                    (try_begin),
                        (ge, "$g_tutorial_training_ground_current_score", 5),
                        (assign, "$g_tutorial_mouse_dir", -1),
                        (assign, "$g_tutorial_mouse_click", -1),
                        (tutorial_message, -1),
                        (assign, "$g_tutorial_training_ground_melee_state", 0),
                        (agent_set_team, ":var_0", 0),
                        (agent_set_team, ":var_3", 7),
                        (agent_set_hit_points, ":var_0", 100, 0),
                        (agent_set_hit_points, ":var_3", 100, 0),
                        (assign, "$g_tutorial_training_ground_conversation_state", 1),
                        (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_parry"),
                        (assign, "$g_tutorial_training_ground_melee_trainer_parry", -1),
                    (else_try),
                        (store_random_in_range, ":var_7", 0, 4),
                        (agent_set_attack_action, ":var_3", ":var_7", 1),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                        (assign, "$g_tutorial_mouse_dir", ":var_7"),
                        (try_begin),
                            (is_between, ":var_7", 1, 3),
                            (store_sub, "$g_tutorial_mouse_dir", 3, ":var_7"),
                        (try_end),
                        (assign, "$g_tutorial_mouse_click", 1),
                        (start_presentation, "prsnt_tutorial_show_mouse_movement"),
                    (try_end),
                (else_try),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (agent_get_defend_action, ":var_8", ":var_0"),
                    (gt, ":var_8", 0),
                    (agent_get_action_dir, ":var_9", ":var_0"),
                    (agent_get_action_dir, ":var_10", ":var_3"),
                    (assign, ":var_11", 0),
                    (try_begin),
                        (eq, ":var_10", 0),
                        (eq, ":var_9", 0),
                        (assign, ":var_11", 1),
                    (else_try),
                        (eq, ":var_10", 3),
                        (eq, ":var_9", 3),
                        (assign, ":var_11", 1),
                    (else_try),
                        (eq, ":var_10", 1),
                        (eq, ":var_9", 2),
                        (assign, ":var_11", 1),
                    (else_try),
                        (eq, ":var_10", 2),
                        (eq, ":var_9", 1),
                        (assign, ":var_11", 1),
                    (try_end),
                    (eq, ":var_11", 1),
                    (assign, "$g_tutorial_mouse_dir", -1),
                    (assign, "$g_tutorial_mouse_click", -1),
                    (agent_set_attack_action, ":var_3", 0, 0),
                    (val_add, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (store_mission_timer_a, "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                    (val_add, "$g_tutorial_training_ground_melee_trainer_next_action_time", 2),
                (else_try),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 2),
                    (try_begin),
                        (store_mission_timer_a, ":var_5"),
                        (gt, ":var_5", "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (assign, "$g_tutorial_training_ground_melee_trainer_action_state", 0),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (agent_is_in_parried_animation, ":var_3"),
            (agent_get_wielded_item, ":var_12", ":var_0", 1),
            (eq, ":var_12", -1),
            (agent_get_wielded_item, ":var_13", ":var_0", 0),
            (neg|eq, ":var_13", "itm_practice_dagger"),
            (call_script, "script_cf_is_melee_weapon_for_tutorial", ":var_13"),
            (store_mission_timer_a, ":var_5"),
            (gt, ":var_5", "$g_tutorial_training_ground_next_score_time"),
            (val_add, "$g_tutorial_training_ground_current_score", 1),
            (try_begin),
                (neg|ge, "$g_tutorial_training_ground_current_score", 5),
                (play_sound, "snd_tutorial_1"),
            (else_try),
                (play_sound, "snd_tutorial_2"),
            (try_end),
            (store_add, "$g_tutorial_training_ground_next_score_time", ":var_5", 1),
        (try_end),
        (assign, reg0, "$g_tutorial_training_ground_current_score"),
        (try_begin),
            (agent_get_wielded_item, ":var_12", ":var_0", 1),
            (eq, ":var_12", -1),
            (agent_get_wielded_item, ":var_13", ":var_0", 0),
            (neg|eq, ":var_13", "itm_practice_dagger"),
            (call_script, "script_cf_is_melee_weapon_for_tutorial", ":var_13"),
            (tutorial_message, "str_tutorial_training_ground_parry_training"),
        (else_try),
            (neg|eq, ":var_12", -1),
            (tutorial_message, "str_tutorial_training_ground_warning_shield"),
        (else_try),
            (tutorial_message, "str_tutorial_training_ground_warning_melee_with_parry"),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (neg|eq, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
        (mission_disable_talk),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_chamber"),
            (assign, ":var_3", ":var_1"),
        (try_end),
        (try_begin),
            (eq, "$g_tutorial_training_ground_melee_state", 0),
            (try_begin),
                (try_for_agents, ":var_1"),
                    (agent_get_troop_id, ":var_2", ":var_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_2"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_3"),
                    (eq, ":var_2", "trp_tutorial_fighter_4"),
                    (agent_set_team, ":var_1", 7),
                    (agent_get_slot, ":var_4", ":var_1", slot_agent_spawn_entry_point),
                    (entry_point_get_position, pos1, ":var_4"),
                    (agent_set_scripted_destination, ":var_1", pos1),
                    (agent_force_rethink, ":var_1"),
                (try_end),
                (agent_set_wielded_item, ":var_3", "itm_practice_sword"),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
                (store_mission_timer_a, "$g_tutorial_training_ground_melee_next_action_time"),
                (val_add, "$g_tutorial_training_ground_melee_next_action_time", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_melee_state", 1),
            (try_begin),
                (store_mission_timer_a, ":var_5"),
                (gt, ":var_5", "$g_tutorial_training_ground_melee_next_action_time"),
                (agent_set_team, ":var_0", 1),
                (agent_set_team, ":var_3", 2),
                (agent_get_position, pos1, ":var_0"),
                (agent_set_scripted_destination_no_attack, ":var_3", pos1),
                (agent_get_position, pos2, ":var_3"),
                (get_sq_distance_between_positions, ":var_6", pos1, pos2),
                (neg|ge, ":var_6", 400),
                (try_begin),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 0),
                    (try_begin),
                        (ge, "$g_tutorial_training_ground_current_score", 5),
                        (tutorial_message, -1),
                        (assign, "$g_tutorial_training_ground_melee_state", 0),
                        (agent_set_team, ":var_0", 0),
                        (agent_set_team, ":var_3", 7),
                        (agent_set_hit_points, ":var_0", 100, 0),
                        (agent_set_hit_points, ":var_3", 100, 0),
                        (assign, "$g_tutorial_training_ground_conversation_state", 6),
                        (start_mission_conversation, "$g_tutorial_training_ground_melee_trainer_chamber"),
                        (assign, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
                    (else_try),
                        (store_random_in_range, "$g_tutorial_training_ground_melee_trainer_attack_dir", 0, 4),
                        (agent_set_attack_action, ":var_3", "$g_tutorial_training_ground_melee_trainer_attack_dir", 1),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                        (store_mission_timer_a, "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_next_action_time", 1),
                    (try_end),
                (else_try),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                    (try_begin),
                        (store_mission_timer_a, ":var_5"),
                        (gt, ":var_5", "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (agent_set_attack_action, ":var_3", -1, 0),
                        (agent_set_defend_action, ":var_3", 0, 1),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                        (store_mission_timer_a, "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_next_action_time", 1),
                    (try_end),
                (else_try),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 2),
                    (try_begin),
                        (store_mission_timer_a, ":var_5"),
                        (gt, ":var_5", "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (agent_set_attack_action, ":var_3", "$g_tutorial_training_ground_melee_trainer_attack_dir", 0),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_action_state", 1),
                        (store_mission_timer_a, "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (val_add, "$g_tutorial_training_ground_melee_trainer_next_action_time", 2),
                    (try_end),
                (else_try),
                    (eq, "$g_tutorial_training_ground_melee_trainer_action_state", 3),
                    (try_begin),
                        (store_mission_timer_a, ":var_5"),
                        (gt, ":var_5", "$g_tutorial_training_ground_melee_trainer_next_action_time"),
                        (assign, "$g_tutorial_training_ground_melee_trainer_action_state", 0),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (agent_is_in_parried_animation, ":var_3"),
            (agent_get_attack_action, ":var_7", ":var_0"),
            (store_mission_timer_a, ":var_5"),
            (gt, ":var_5", "$g_tutorial_training_ground_next_score_time"),
            (store_add, "$g_tutorial_training_ground_next_score_time", ":var_5", 1),
            (eq, ":var_7", 1),
            (val_add, "$g_tutorial_training_ground_current_score", 1),
            (try_begin),
                (neg|ge, "$g_tutorial_training_ground_current_score", 5),
                (play_sound, "snd_tutorial_1"),
            (else_try),
                (play_sound, "snd_tutorial_2"),
            (try_end),
        (try_end),
        (assign, reg0, "$g_tutorial_training_ground_current_score"),
        (tutorial_message, "str_tutorial_training_ground_chamber_training"),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (get_player_agent_no, ":var_0"),
        (neg|eq, "$g_tutorial_training_ground_melee_trainer_combat", -1),
        (mission_disable_talk),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (eq, ":var_2", "$g_tutorial_training_ground_melee_trainer_combat"),
            (assign, ":var_3", ":var_1"),
        (try_end),
        (try_begin),
            (eq, "$g_tutorial_training_ground_melee_state", 0),
            (try_begin),
                (try_for_agents, ":var_1"),
                    (agent_get_troop_id, ":var_2", ":var_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_1"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_2"),
                    (this_or_next|eq, ":var_2", "trp_tutorial_fighter_3"),
                    (eq, ":var_2", "trp_tutorial_fighter_4"),
                    (agent_set_team, ":var_1", 7),
                    (agent_get_slot, ":var_4", ":var_1", slot_agent_spawn_entry_point),
                    (entry_point_get_position, pos1, ":var_4"),
                    (agent_set_scripted_destination, ":var_1", pos1),
                    (agent_force_rethink, ":var_1"),
                (try_end),
                (agent_set_wielded_item, ":var_3", "itm_practice_sword"),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
                (store_mission_timer_a, "$g_tutorial_training_ground_melee_next_action_time"),
                (val_add, "$g_tutorial_training_ground_melee_next_action_time", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_melee_state", 1),
            (try_begin),
                (store_mission_timer_a, ":var_5"),
                (gt, ":var_5", "$g_tutorial_training_ground_melee_next_action_time"),
                (agent_set_team, ":var_0", 1),
                (agent_set_team, ":var_3", 2),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_tutorial_training_ground_melee_trainer_attack", -1),
        (eq, "$g_tutorial_training_ground_melee_trainer_parry", -1),
        (eq, "$g_tutorial_training_ground_melee_trainer_combat", -1),
        (eq, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
        (eq, "$g_tutorial_training_ground_archer_trainer_state", 0),
        (eq, "$g_tutorial_training_ground_horseman_trainer_state", 0),
        (mission_enable_talk),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_tutorial_training_ground_melee_trainer_attack", -1),
        (eq, "$g_tutorial_training_ground_melee_trainer_parry", -1),
        (eq, "$g_tutorial_training_ground_melee_trainer_combat", -1),
        (eq, "$g_tutorial_training_ground_melee_trainer_chamber", -1),
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_1", 10000000),
        (try_for_agents, ":var_2"),
            (agent_get_troop_id, ":var_3", ":var_2"),
            (this_or_next|eq, ":var_3", "trp_tutorial_fighter_1"),
            (this_or_next|eq, ":var_3", "trp_tutorial_fighter_2"),
            (this_or_next|eq, ":var_3", "trp_tutorial_fighter_3"),
            (eq, ":var_3", "trp_tutorial_fighter_4"),
            (agent_get_position, pos2, ":var_2"),
            (get_sq_distance_between_positions, ":var_4", pos1, pos2),
            (neg|ge, ":var_4", ":var_1"),
            (assign, ":var_1", ":var_4"),
        (try_end),
        (try_begin),
            (neg|gt, ":var_1", 1600),
            (assign, "$g_tutorial_training_ground_melee_paused", 1),
            (try_for_agents, ":var_2"),
                (agent_get_troop_id, ":var_3", ":var_2"),
                (this_or_next|eq, ":var_3", "trp_tutorial_fighter_1"),
                (this_or_next|eq, ":var_3", "trp_tutorial_fighter_2"),
                (this_or_next|eq, ":var_3", "trp_tutorial_fighter_3"),
                (eq, ":var_3", "trp_tutorial_fighter_4"),
                (agent_set_team, ":var_2", 7),
                (agent_get_position, pos2, ":var_2"),
                (agent_set_scripted_destination, ":var_2", pos2),
                (try_begin),
                    (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                    (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                    (agent_set_wielded_item, ":var_2", -1),
                (try_end),
                (agent_force_rethink, ":var_2"),
                (agent_set_look_target_agent, ":var_2", ":var_0"),
            (try_end),
        (else_try),
            (gt, "$g_tutorial_training_ground_melee_paused", 0),
            (assign, "$g_tutorial_training_ground_melee_paused", 0),
            (assign, "$g_tutorial_training_ground_melee_state", 0),
        (try_end),
        (try_begin),
            (eq, "$g_tutorial_training_ground_melee_paused", 0),
            (eq, "$g_tutorial_training_ground_melee_state", 0),
            (try_begin),
                (assign, "$g_tutorial_training_ground_melee_cur_fighter_1", -1),
                (assign, "$g_tutorial_training_ground_melee_cur_fighter_2", -1),
                (try_for_range, ":var_5", 0, 2),
                    (try_begin),
                        (ge, "$g_tutorial_training_ground_melee_last_winner", 0),
                        (assign, "$g_tutorial_training_ground_melee_cur_fighter_1", "$g_tutorial_training_ground_melee_last_winner"),
                        (assign, "$g_tutorial_training_ground_melee_last_winner", -1),
                    (try_end),
                    (this_or_next|eq, "$g_tutorial_training_ground_melee_cur_fighter_1", -1),
                    (eq, "$g_tutorial_training_ground_melee_cur_fighter_2", -1),
                    (assign, ":var_6", 0),
                    (try_for_agents, ":var_2"),
                        (agent_get_troop_id, ":var_3", ":var_2"),
                        (this_or_next|eq, ":var_3", "trp_tutorial_fighter_1"),
                        (this_or_next|eq, ":var_3", "trp_tutorial_fighter_2"),
                        (this_or_next|eq, ":var_3", "trp_tutorial_fighter_3"),
                        (eq, ":var_3", "trp_tutorial_fighter_4"),
                        (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                        (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                        (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_last_loser"),
                        (val_add, ":var_6", 1),
                    (try_end),
                    (store_random_in_range, ":var_7", 0, ":var_6"),
                    (try_for_agents, ":var_2"),
                        (agent_get_troop_id, ":var_3", ":var_2"),
                        (this_or_next|eq, ":var_3", "trp_tutorial_fighter_1"),
                        (this_or_next|eq, ":var_3", "trp_tutorial_fighter_2"),
                        (this_or_next|eq, ":var_3", "trp_tutorial_fighter_3"),
                        (eq, ":var_3", "trp_tutorial_fighter_4"),
                        (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                        (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                        (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_last_loser"),
                        (val_sub, ":var_7", 1),
                        (neg|ge, ":var_7", 0),
                        (try_begin),
                            (eq, "$g_tutorial_training_ground_melee_cur_fighter_1", -1),
                            (assign, "$g_tutorial_training_ground_melee_cur_fighter_1", ":var_2"),
                        (else_try),
                            (assign, "$g_tutorial_training_ground_melee_cur_fighter_2", ":var_2"),
                        (try_end),
                    (try_end),
                (try_end),
                (try_for_agents, ":var_2"),
                    (agent_get_troop_id, ":var_3", ":var_2"),
                    (this_or_next|eq, ":var_3", "trp_tutorial_fighter_1"),
                    (this_or_next|eq, ":var_3", "trp_tutorial_fighter_2"),
                    (this_or_next|eq, ":var_3", "trp_tutorial_fighter_3"),
                    (eq, ":var_3", "trp_tutorial_fighter_4"),
                    (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                    (neg|eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                    (agent_set_wielded_item, ":var_2", -1),
                (try_end),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
                (store_mission_timer_a, "$g_tutorial_training_ground_melee_next_action_time"),
                (val_add, "$g_tutorial_training_ground_melee_next_action_time", 3),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_melee_state", 1),
            (try_begin),
                (store_mission_timer_a, ":var_8"),
                (gt, ":var_8", "$g_tutorial_training_ground_melee_next_action_time"),
                (try_for_agents, ":var_2"),
                    (agent_is_human, ":var_2"),
                    (agent_get_troop_id, ":var_3", ":var_2"),
                    (this_or_next|eq, ":var_3", "trp_tutorial_fighter_1"),
                    (this_or_next|eq, ":var_3", "trp_tutorial_fighter_2"),
                    (this_or_next|eq, ":var_3", "trp_tutorial_fighter_3"),
                    (eq, ":var_3", "trp_tutorial_fighter_4"),
                    (try_begin),
                        (eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                        (entry_point_get_position, pos1, 30),
                        (agent_set_scripted_destination, ":var_2", pos1),
                    (else_try),
                        (eq, ":var_2", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                        (entry_point_get_position, pos1, 31),
                        (agent_set_scripted_destination, ":var_2", pos1),
                    (else_try),
                        (agent_get_slot, ":var_9", ":var_2", slot_agent_spawn_entry_point),
                        (entry_point_get_position, pos1, ":var_9"),
                        (agent_set_scripted_destination, ":var_2", pos1),
                    (try_end),
                (try_end),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_melee_state", 2),
            (try_begin),
                (agent_set_look_target_agent, "$g_tutorial_training_ground_melee_cur_fighter_1", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                (agent_set_look_target_agent, "$g_tutorial_training_ground_melee_cur_fighter_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                (agent_get_position, pos1, "$g_tutorial_training_ground_melee_cur_fighter_1"),
                (entry_point_get_position, pos2, 30),
                (get_sq_distance_between_positions, ":var_10", pos1, pos2),
                (neg|ge, ":var_10", 400),
                (agent_get_position, pos1, "$g_tutorial_training_ground_melee_cur_fighter_2"),
                (entry_point_get_position, pos2, 31),
                (get_sq_distance_between_positions, ":var_11", pos1, pos2),
                (neg|ge, ":var_11", 400),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
                (store_mission_timer_a, "$g_tutorial_training_ground_melee_next_action_time"),
                (val_add, "$g_tutorial_training_ground_melee_next_action_time", 1),
            (try_end),
        (else_try),
            (eq, "$g_tutorial_training_ground_melee_state", 3),
            (try_begin),
                (agent_set_look_target_agent, "$g_tutorial_training_ground_melee_cur_fighter_1", "$g_tutorial_training_ground_melee_cur_fighter_2"),
                (agent_set_look_target_agent, "$g_tutorial_training_ground_melee_cur_fighter_2", "$g_tutorial_training_ground_melee_cur_fighter_1"),
                (store_mission_timer_a, ":var_8"),
                (gt, ":var_8", "$g_tutorial_training_ground_melee_next_action_time"),
                (agent_clear_scripted_mode, "$g_tutorial_training_ground_melee_cur_fighter_1"),
                (agent_clear_scripted_mode, "$g_tutorial_training_ground_melee_cur_fighter_2"),
                (agent_set_team, "$g_tutorial_training_ground_melee_cur_fighter_1", 1),
                (agent_set_team, "$g_tutorial_training_ground_melee_cur_fighter_2", 2),
                (agent_force_rethink, "$g_tutorial_training_ground_melee_cur_fighter_1"),
                (agent_force_rethink, "$g_tutorial_training_ground_melee_cur_fighter_2"),
                (val_add, "$g_tutorial_training_ground_melee_state", 1),
            (try_end),
        (try_end),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"tutorial_1", 0, -1, 
"You_enter_the_training_ground.",
[(0, mtef_no_companions|mtef_no_regulars, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_tutorial_shield, itm_tutorial_sword, itm_tutorial_short_bow, itm_tutorial_arrows, itm_leather_jerkin, itm_leather_boots]),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$tutorial_1_state", 5),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (assign, "$tutorial_1_state", 0),
        (assign, "$tutorial_1_msg_1_displayed", 0),
        (assign, "$tutorial_1_msg_2_displayed", 0),
        (assign, "$tutorial_1_msg_3_displayed", 0),
        (assign, "$tutorial_1_msg_4_displayed", 0),
        (assign, "$tutorial_1_msg_5_displayed", 0),
        (assign, "$tutorial_1_msg_6_displayed", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$tutorial_1_state", 0),
            (try_begin),
                (eq, "$tutorial_1_msg_1_displayed", 0),
                (store_mission_timer_a, ":var_0"),
                (gt, ":var_0", 0),
                (assign, "$tutorial_1_msg_1_displayed", 1),
                (tutorial_message, "str_tutorial_1_msg_1"),
                (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
                (entry_point_get_position, pos1, 1),
                (prop_instance_animate_to_position, ":var_1", 1, 1),
            (try_end),
            (tutorial_message, "str_tutorial_1_msg_1"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos1, ":var_2"),
            (entry_point_get_position, pos2, 1),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 100),
            (val_add, "$tutorial_1_state", 1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
            (entry_point_get_position, pos1, 2),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
        (else_try),
            (eq, "$tutorial_1_state", 1),
            (try_begin),
                (eq, "$tutorial_1_msg_2_displayed", 0),
                (assign, "$tutorial_1_msg_2_displayed", 1),
                (tutorial_message, "str_tutorial_1_msg_2"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos1, ":var_2"),
            (entry_point_get_position, pos2, 2),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 100),
            (val_add, "$tutorial_1_state", 1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 1),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
            (entry_point_get_position, pos1, 3),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
        (else_try),
            (eq, "$tutorial_1_state", 2),
            (try_begin),
                (eq, "$tutorial_1_msg_3_displayed", 0),
                (assign, "$tutorial_1_msg_3_displayed", 1),
                (tutorial_message, "str_tutorial_1_msg_3"),
                (assign, "$tutorial_num_total_dummies_destroyed", 0),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (ge, "$tutorial_num_total_dummies_destroyed", 4),
            (val_add, "$tutorial_1_state", 1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 2),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
        (else_try),
            (eq, "$tutorial_1_state", 3),
            (try_begin),
                (eq, "$tutorial_1_msg_4_displayed", 0),
                (assign, "$tutorial_1_msg_4_displayed", 1),
                (tutorial_message, "str_tutorial_1_msg_4"),
                (store_mission_timer_a, "$tutorial_time"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (store_mission_timer_a, ":var_0"),
            (val_sub, ":var_0", "$tutorial_time"),
            (gt, ":var_0", 10),
            (val_add, "$tutorial_1_state", 1),
        (else_try),
            (eq, "$tutorial_1_state", 4),
            (try_begin),
                (eq, "$tutorial_1_msg_5_displayed", 0),
                (assign, "$tutorial_1_msg_5_displayed", 1),
                (tutorial_message, "str_tutorial_1_msg_5"),
                (assign, "$g_last_archery_point_earned", 0),
                (assign, "$tutorial_num_arrows_hit", 0),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (try_begin),
                (get_player_agent_no, ":var_2"),
                (agent_get_ammo, ":var_5", ":var_2"),
                (neg|gt, ":var_5", 0),
                (agent_refill_ammo, ":var_2"),
                (tutorial_message, "str_tutorial_ammo_refilled"),
            (try_end),
            (gt, "$g_last_archery_point_earned", 0),
            (assign, "$g_last_archery_point_earned", 0),
            (val_add, "$tutorial_num_arrows_hit", 1),
            (gt, "$tutorial_num_arrows_hit", 2),
            (val_add, "$tutorial_1_state", 1),
        (else_try),
            (eq, "$tutorial_1_state", 5),
            (eq, "$tutorial_1_msg_6_displayed", 0),
            (assign, "$tutorial_1_msg_6_displayed", 1),
            (tutorial_message, "str_tutorial_1_msg_6"),
            (play_sound, "snd_tutorial_2"),
            (assign, "$tutorial_1_finished", 1),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"tutorial_2", 1, -1, 
"You_enter_the_training_ground.",
[(0, mtef_no_companions|mtef_no_regulars|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_tutorial_shield, itm_leather_jerkin, itm_leather_boots]),
(2, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_1, 0, 0, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$tutorial_2_state", 9),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (gt, ":var_0", 2),
        (main_hero_fallen),
        (assign, "$tutorial_2_state", 100),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (assign, "$tutorial_2_state", 0),
        (assign, "$tutorial_2_msg_1_displayed", 0),
        (assign, "$tutorial_2_msg_2_displayed", 0),
        (assign, "$tutorial_2_msg_3_displayed", 0),
        (assign, "$tutorial_2_msg_4_displayed", 0),
        (assign, "$tutorial_2_msg_5_displayed", 0),
        (assign, "$tutorial_2_msg_6_displayed", 0),
        (assign, "$tutorial_2_msg_7_displayed", 0),
        (assign, "$tutorial_2_msg_8_displayed", 0),
        (assign, "$tutorial_2_msg_9_displayed", 0),
        (assign, "$tutorial_2_melee_agent_state", 0),
    ],
    [
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_archer"),
        (agent_refill_ammo, reg0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$tutorial_2_state", 0),
            (try_begin),
                (eq, "$tutorial_2_msg_1_displayed", 0),
                (store_mission_timer_a, ":var_0"),
                (gt, ":var_0", 0),
                (assign, "$tutorial_2_msg_1_displayed", 1),
                (tutorial_message, "str_tutorial_2_msg_1"),
                (team_give_order, 1, 9, 11),
                (team_give_order, 1, 0, 2),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (agent_get_position, pos1, ":var_1"),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
            (try_end),
            (get_player_agent_no, ":var_2"),
            (ge, ":var_2", 0),
            (agent_get_position, pos1, ":var_2"),
            (entry_point_get_position, pos2, 1),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 200),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 1),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 0),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 2),
            (get_player_agent_no, ":var_2"),
            (agent_set_kick_allowed, ":var_2", 0),
            (try_begin),
                (eq, "$tutorial_2_melee_agent_state", 0),
                (val_add, "$tutorial_2_melee_agent_state", 1),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (entry_point_get_position, pos1, 3),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
            (else_try),
                (eq, "$tutorial_2_melee_agent_state", 1),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (entry_point_get_position, pos1, 3),
                (agent_get_position, pos2, ":var_1"),
                (get_distance_between_positions, ":var_3", pos1, pos2),
                (neg|gt, ":var_3", 250),
                (agent_clear_scripted_mode, ":var_1"),
                (val_add, "$tutorial_2_melee_agent_state", 1),
                (store_mission_timer_a, "$tutorial_time"),
            (else_try),
                (eq, "$tutorial_2_melee_agent_state", 2),
                (try_begin),
                    (eq, "$tutorial_2_msg_2_displayed", 0),
                    (assign, "$tutorial_2_msg_2_displayed", 1),
                    (play_sound, "snd_tutorial_1"),
                (try_end),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (store_mission_timer_a, ":var_0"),
                (val_sub, ":var_0", "$tutorial_time"),
                (store_sub, reg3, 20, ":var_0"),
                (tutorial_message, "str_tutorial_2_msg_2"),
                (gt, ":var_0", 20),
                (entry_point_get_position, pos1, 3),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
                (val_add, "$tutorial_2_melee_agent_state", 1),
            (else_try),
                (eq, "$tutorial_2_melee_agent_state", 3),
                (try_begin),
                    (eq, "$tutorial_2_msg_3_displayed", 0),
                    (assign, "$tutorial_2_msg_3_displayed", 1),
                    (tutorial_message, "str_tutorial_2_msg_3"),
                    (play_sound, "snd_tutorial_1"),
                (try_end),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (entry_point_get_position, pos1, 3),
                (agent_get_position, pos2, ":var_1"),
                (get_distance_between_positions, ":var_3", pos1, pos2),
                (neg|gt, ":var_3", 250),
                (entry_point_get_position, pos1, 2),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
                (val_add, "$tutorial_2_melee_agent_state", 1),
            (else_try),
                (eq, "$tutorial_2_melee_agent_state", 4),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (entry_point_get_position, pos1, 2),
                (agent_get_position, pos2, ":var_1"),
                (get_distance_between_positions, ":var_3", pos1, pos2),
                (neg|gt, ":var_3", 250),
                (entry_point_get_position, pos1, 30),
                (agent_set_position, ":var_1", pos1),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
                (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 1),
                (prop_instance_get_position, pos1, ":var_4"),
                (position_rotate_z, pos1, 90),
                (prop_instance_animate_to_position, ":var_4", 1, 150),
                (val_add, "$tutorial_2_melee_agent_state", 1),
                (val_add, "$tutorial_2_state", 1),
            (try_end),
        (else_try),
            (eq, "$tutorial_2_state", 3),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 1),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_set_kick_allowed, ":var_2", 1),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 1),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (store_mission_timer_a, "$tutorial_time"),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 4),
            (try_begin),
                (eq, "$tutorial_2_msg_4_displayed", 0),
                (assign, "$tutorial_2_msg_4_displayed", 1),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (store_mission_timer_a, ":var_0"),
            (val_sub, ":var_0", "$tutorial_time"),
            (store_sub, reg3, 20, ":var_0"),
            (tutorial_message, "str_tutorial_2_msg_4"),
            (gt, ":var_0", 20),
            (entry_point_get_position, pos1, 5),
            (set_spawn_position, pos1),
            (spawn_item, "itm_tutorial_sword"),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 3),
            (agent_set_position, ":var_1", pos1),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 2),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 5),
            (try_begin),
                (eq, "$tutorial_2_msg_5_displayed", 0),
                (assign, "$tutorial_2_msg_5_displayed", 1),
                (tutorial_message, "str_tutorial_2_msg_5"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 2),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 2),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 6),
            (try_begin),
                (eq, "$tutorial_2_msg_6_displayed", 0),
                (assign, "$tutorial_2_msg_6_displayed", 1),
                (tutorial_message, "str_tutorial_2_msg_6"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_2"),
            (agent_has_item_equipped, ":var_2", "itm_tutorial_sword"),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 3),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 7),
            (try_begin),
                (eq, "$tutorial_2_msg_7_displayed", 0),
                (assign, "$tutorial_2_msg_7_displayed", 1),
                (tutorial_message, "str_tutorial_2_msg_7"),
                (play_sound, "snd_tutorial_1"),
                (get_player_agent_no, ":var_2"),
                (agent_set_hit_points, ":var_2", 100),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_archer"),
            (assign, ":var_1", reg0),
            (neg|agent_is_alive, ":var_1"),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (agent_clear_scripted_mode, ":var_1"),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_a", 4),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 8),
            (try_begin),
                (eq, "$tutorial_2_msg_8_displayed", 0),
                (assign, "$tutorial_2_msg_8_displayed", 1),
                (tutorial_message, "str_tutorial_2_msg_8"),
                (play_sound, "snd_tutorial_1"),
                (get_player_agent_no, ":var_2"),
                (agent_set_hit_points, ":var_2", 100),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (neg|agent_is_alive, ":var_1"),
            (val_add, "$tutorial_2_state", 1),
        (else_try),
            (eq, "$tutorial_2_state", 9),
            (eq, "$tutorial_2_msg_9_displayed", 0),
            (assign, "$tutorial_2_msg_9_displayed", 1),
            (tutorial_message, "str_tutorial_2_msg_9"),
            (play_sound, "snd_tutorial_2"),
            (assign, "$tutorial_2_finished", 1),
        (else_try),
            (gt, "$tutorial_2_state", 30),
            (tutorial_message, "str_tutorial_failed"),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"tutorial_3", 1, -1, 
"You_enter_the_training_ground.",
[(0, mtef_no_companions|mtef_no_regulars|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_leather_jerkin, itm_leather_boots]),
(3, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$tutorial_3_state", 12),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (gt, ":var_0", 2),
        (main_hero_fallen),
        (assign, "$tutorial_3_state", 100),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (assign, "$tutorial_3_state", 0),
        (assign, "$tutorial_3_msg_1_displayed", 0),
        (assign, "$tutorial_3_msg_2_displayed", 0),
        (assign, "$tutorial_3_msg_3_displayed", 0),
        (assign, "$tutorial_3_msg_4_displayed", 0),
        (assign, "$tutorial_3_msg_5_displayed", 0),
        (assign, "$tutorial_3_msg_6_displayed", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$tutorial_3_state", 0),
            (try_begin),
                (eq, "$tutorial_3_msg_1_displayed", 0),
                (store_mission_timer_a, ":var_0"),
                (gt, ":var_0", 0),
                (assign, "$tutorial_3_msg_1_displayed", 1),
                (tutorial_message, "str_tutorial_3_msg_1"),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (agent_get_position, pos1, ":var_1"),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
                (assign, ":var_1", reg0),
                (agent_get_position, pos1, ":var_1"),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
                (entry_point_get_position, pos1, 1),
                (set_spawn_position, pos1),
                (spawn_item, "itm_tutorial_staff_no_attack"),
            (try_end),
            (get_player_agent_no, ":var_2"),
            (ge, ":var_2", 0),
            (agent_has_item_equipped, ":var_2", "itm_tutorial_staff_no_attack"),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 1),
            (try_begin),
                (eq, "$tutorial_3_msg_2_displayed", 0),
                (assign, "$tutorial_3_msg_2_displayed", 1),
                (tutorial_message, "str_tutorial_3_msg_2"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos1, ":var_2"),
            (entry_point_get_position, pos2, 2),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 200),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 2),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 0),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 3),
            (get_player_agent_no, ":var_2"),
            (agent_set_kick_allowed, ":var_2", 0),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 4),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 4),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 4),
            (agent_get_position, pos2, ":var_1"),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 250),
            (agent_clear_scripted_mode, ":var_1"),
            (val_add, "$tutorial_3_state", 1),
            (store_mission_timer_a, "$tutorial_time"),
        (else_try),
            (eq, "$tutorial_3_state", 5),
            (try_begin),
                (eq, "$tutorial_3_msg_3_displayed", 0),
                (assign, "$tutorial_3_msg_3_displayed", 1),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (store_mission_timer_a, ":var_0"),
            (val_sub, ":var_0", "$tutorial_time"),
            (store_sub, reg3, 20, ":var_0"),
            (tutorial_message, "str_tutorial_3_msg_3"),
            (gt, ":var_0", 20),
            (entry_point_get_position, pos1, 4),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 6),
            (try_begin),
                (eq, "$tutorial_3_msg_4_displayed", 0),
                (assign, "$tutorial_3_msg_4_displayed", 1),
                (tutorial_message, "str_tutorial_3_msg_4"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 4),
            (agent_get_position, pos2, ":var_1"),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 250),
            (entry_point_get_position, pos1, 3),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 7),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 3),
            (agent_get_position, pos2, ":var_1"),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 250),
            (entry_point_get_position, pos1, 7),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (agent_set_position, ":var_1", pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 1),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 3),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 8),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 1),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 1),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 9),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 6),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 10),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 6),
            (agent_get_position, pos2, ":var_1"),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 250),
            (agent_clear_scripted_mode, ":var_1"),
            (val_add, "$tutorial_3_state", 1),
            (store_mission_timer_a, "$tutorial_time"),
        (else_try),
            (eq, "$tutorial_3_state", 11),
            (try_begin),
                (eq, "$tutorial_3_msg_5_displayed", 0),
                (assign, "$tutorial_3_msg_5_displayed", 1),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (assign, ":var_1", reg0),
            (store_mission_timer_a, ":var_0"),
            (val_sub, ":var_0", "$tutorial_time"),
            (store_sub, reg3, 20, ":var_0"),
            (tutorial_message, "str_tutorial_3_msg_5"),
            (gt, ":var_0", 20),
            (entry_point_get_position, pos1, 6),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 12),
            (try_begin),
                (eq, "$tutorial_3_msg_6_displayed", 0),
                (assign, "$tutorial_3_msg_6_displayed", 1),
                (tutorial_message, "str_tutorial_3_msg_6"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 6),
            (agent_get_position, pos2, ":var_1"),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 250),
            (entry_point_get_position, pos1, 5),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 13),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (assign, ":var_1", reg0),
            (entry_point_get_position, pos1, 5),
            (agent_get_position, pos2, ":var_1"),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 250),
            (entry_point_get_position, pos1, 7),
            (agent_set_scripted_destination, ":var_1", pos1, 0),
            (agent_set_position, ":var_1", pos1),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (gt, "$tutorial_3_state", 30),
            (tutorial_message, "str_tutorial_failed"),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"tutorial_3_2", 1, -1, 
"You_enter_the_training_ground.",
[(0, mtef_no_companions|mtef_no_regulars|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_tutorial_staff, itm_leather_jerkin, itm_leather_boots]),
(4, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$tutorial_3_state", 5),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (gt, ":var_0", 2),
        (main_hero_fallen),
        (assign, "$tutorial_3_state", 100),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (assign, "$tutorial_3_state", 0),
        (assign, "$tutorial_3_msg_1_displayed", 0),
        (assign, "$tutorial_3_msg_2_displayed", 0),
        (assign, "$tutorial_3_msg_3_displayed", 0),
        (assign, "$tutorial_3_msg_4_displayed", 0),
        (assign, "$tutorial_3_msg_5_displayed", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$tutorial_3_state", 0),
            (try_begin),
                (eq, "$tutorial_3_msg_1_displayed", 0),
                (store_mission_timer_a, ":var_0"),
                (gt, ":var_0", 0),
                (assign, "$tutorial_3_msg_1_displayed", 1),
                (tutorial_message, "str_tutorial_3_2_msg_1"),
                (play_sound, "snd_tutorial_1"),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
                (assign, ":var_1", reg0),
                (agent_get_position, pos1, ":var_1"),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
                (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
                (assign, ":var_1", reg0),
                (agent_get_position, pos1, ":var_1"),
                (agent_set_scripted_destination, ":var_1", pos1, 0),
            (try_end),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos1, ":var_2"),
            (entry_point_get_position, pos2, 2),
            (get_distance_between_positions, ":var_3", pos1, pos2),
            (neg|gt, ":var_3", 200),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 1),
            (try_begin),
                (eq, "$tutorial_3_msg_2_displayed", 0),
                (assign, "$tutorial_3_msg_2_displayed", 1),
                (tutorial_message, "str_tutorial_3_2_msg_2"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 0),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 0),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (agent_clear_scripted_mode, reg0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 2),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_maceman"),
            (neg|agent_is_alive, reg0),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 1),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 3),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, -90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 3),
            (try_begin),
                (eq, "$tutorial_3_msg_3_displayed", 0),
                (assign, "$tutorial_3_msg_3_displayed", 1),
                (tutorial_message, "str_tutorial_3_2_msg_3"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (scene_prop_get_instance, ":var_5", "spr_barrier_4m", 1),
            (prop_instance_get_position, pos1, ":var_5"),
            (get_player_agent_no, ":var_2"),
            (agent_get_position, pos2, ":var_2"),
            (position_is_behind_position, pos2, pos1),
            (scene_prop_get_instance, ":var_4", "spr_tutorial_door_b", 1),
            (prop_instance_get_position, pos1, ":var_4"),
            (position_rotate_z, pos1, 90),
            (prop_instance_animate_to_position, ":var_4", 1, 150),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (agent_clear_scripted_mode, reg0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 4),
            (try_begin),
                (eq, "$tutorial_3_msg_4_displayed", 0),
                (assign, "$tutorial_3_msg_4_displayed", 1),
                (tutorial_message, "str_tutorial_3_2_msg_4"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_get_first_agent_with_troop_id", "trp_tutorial_swordsman"),
            (neg|agent_is_alive, reg0),
            (val_add, "$tutorial_3_state", 1),
        (else_try),
            (eq, "$tutorial_3_state", 5),
            (eq, "$tutorial_3_msg_5_displayed", 0),
            (assign, "$tutorial_3_msg_5_displayed", 1),
            (tutorial_message, "str_tutorial_3_2_msg_5"),
            (play_sound, "snd_tutorial_2"),
            (assign, "$tutorial_3_finished", 1),
        (else_try),
            (gt, "$tutorial_3_state", 30),
            (tutorial_message, "str_tutorial_failed"),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"tutorial_4", 1, -1, 
"You_enter_the_training_ground.",
[(0, mtef_no_companions|mtef_no_regulars|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_tutorial_sword, itm_tutorial_short_bow, itm_tutorial_arrows, itm_leather_jerkin, itm_leather_boots]),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$tutorial_4_state", 11),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (scene_set_day_time, 13),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (assign, "$tutorial_4_state", 0),
        (assign, "$tutorial_4_msg_1_displayed", 0),
        (assign, "$tutorial_4_msg_2_displayed", 0),
        (assign, "$tutorial_4_msg_3_displayed", 0),
        (assign, "$tutorial_4_msg_4_displayed", 0),
        (assign, "$tutorial_4_msg_5_displayed", 0),
        (assign, "$tutorial_4_msg_6_displayed", 0),
        (assign, "$tutorial_4_msg_7_displayed", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$tutorial_4_state", 0),
            (try_begin),
                (eq, "$tutorial_4_msg_1_displayed", 0),
                (store_mission_timer_a, ":var_0"),
                (gt, ":var_0", 0),
                (assign, "$tutorial_4_msg_1_displayed", 1),
                (tutorial_message, "str_tutorial_4_msg_1"),
                (entry_point_get_position, pos1, 1),
                (set_spawn_position, pos1),
                (spawn_horse, "itm_tutorial_saddle_horse"),
                (assign, "$tutorial_num_total_dummies_destroyed", 0),
            (try_end),
            (get_player_agent_no, ":var_1"),
            (agent_get_horse, ":var_2", ":var_1"),
            (ge, ":var_2", 0),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 2),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 1),
            (try_begin),
                (eq, "$tutorial_4_msg_2_displayed", 0),
                (assign, "$tutorial_4_msg_2_displayed", 1),
                (tutorial_message, "str_tutorial_4_msg_2"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 2),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 3),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 2),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 3),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 4),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 3),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 4),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 5),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 4),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 5),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 6),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 5),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 6),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 1),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 6),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 1),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 7),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 7),
            (try_begin),
                (eq, "$tutorial_4_msg_3_displayed", 0),
                (assign, "$tutorial_4_msg_3_displayed", 1),
                (tutorial_message, "str_tutorial_4_msg_3"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 7),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 20),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 8),
            (try_begin),
                (eq, "$tutorial_4_msg_4_displayed", 0),
                (assign, "$tutorial_4_msg_4_displayed", 1),
                (tutorial_message, "str_tutorial_4_msg_4"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (ge, "$tutorial_num_total_dummies_destroyed", 2),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 8),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 9),
            (try_begin),
                (eq, "$tutorial_4_msg_5_displayed", 0),
                (assign, "$tutorial_4_msg_5_displayed", 1),
                (tutorial_message, "str_tutorial_4_msg_5"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_1"),
            (agent_get_position, pos1, ":var_1"),
            (entry_point_get_position, pos2, 8),
            (get_distance_between_positions, ":var_4", pos1, pos2),
            (neg|gt, ":var_4", 200),
            (val_add, "$tutorial_4_state", 1),
            (entry_point_get_position, pos1, 20),
            (scene_prop_get_instance, ":var_3", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_3", 1, 1),
        (else_try),
            (eq, "$tutorial_4_state", 10),
            (try_begin),
                (eq, "$tutorial_4_msg_6_displayed", 0),
                (assign, "$tutorial_4_msg_6_displayed", 1),
                (tutorial_message, "str_tutorial_4_msg_6"),
                (play_sound, "snd_tutorial_1"),
                (assign, "$g_last_archery_point_earned", 0),
                (assign, "$tutorial_num_arrows_hit", 0),
            (try_end),
            (try_begin),
                (get_player_agent_no, ":var_1"),
                (agent_get_ammo, ":var_5", ":var_1"),
                (neg|gt, ":var_5", 0),
                (agent_refill_ammo, ":var_1"),
                (tutorial_message, "str_tutorial_ammo_refilled"),
            (try_end),
            (gt, "$g_last_archery_point_earned", 0),
            (assign, "$g_last_archery_point_earned", 0),
            (val_add, "$tutorial_num_arrows_hit", 1),
            (gt, "$tutorial_num_arrows_hit", 2),
            (val_add, "$tutorial_4_state", 1),
        (else_try),
            (eq, "$tutorial_4_state", 11),
            (eq, "$tutorial_4_msg_7_displayed", 0),
            (assign, "$tutorial_4_msg_7_displayed", 1),
            (tutorial_message, "str_tutorial_4_msg_7"),
            (play_sound, "snd_tutorial_2"),
            (assign, "$tutorial_4_finished", 1),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"tutorial_5", 1, -1, 
"You_enter_the_training_ground.",
[(0, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_head|af_override_body|af_override_foot|af_override_gloves|af_override_horse, 0, 1, [itm_tutorial_sword, itm_tutorial_shield, itm_tutorial_short_bow, itm_tutorial_arrows, itm_tutorial_saddle_horse, itm_leather_jerkin, itm_leather_boots]),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(14, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(15, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(16, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|ge, "$tutorial_5_state", 5),
            (question_box, "str_do_you_wish_to_leave_tutorial"),
        (else_try),
            (finish_mission, 0),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (finish_mission, 0),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_tutorial"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (store_mission_timer_a, ":var_0"),
        (gt, ":var_0", 2),
        (main_hero_fallen),
        (assign, "$tutorial_5_state", 100),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (assign, "$tutorial_5_state", 0),
        (assign, "$tutorial_5_msg_1_displayed", 0),
        (assign, "$tutorial_5_msg_2_displayed", 0),
        (assign, "$tutorial_5_msg_3_displayed", 0),
        (assign, "$tutorial_5_msg_4_displayed", 0),
        (assign, "$tutorial_5_msg_5_displayed", 0),
        (assign, "$tutorial_5_msg_6_displayed", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (set_show_messages, 0),
        (team_give_order, 0, 9, 11),
        (set_show_messages, 1),
        (store_mission_timer_a, ":var_0"),
        (gt, ":var_0", 3),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_cf_turn_windmill_fans", 0),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$tutorial_5_state", 0),
            (try_begin),
                (eq, "$tutorial_5_msg_1_displayed", 0),
                (store_mission_timer_a, ":var_0"),
                (gt, ":var_0", 0),
                (assign, "$tutorial_5_msg_1_displayed", 1),
                (tutorial_message, "str_tutorial_5_msg_1"),
                (entry_point_get_position, pos1, 5),
                (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
                (prop_instance_animate_to_position, ":var_1", 1, 1),
            (try_end),
            (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", 0, 0),
            (entry_point_get_position, pos2, 5),
            (get_distance_between_positions, ":var_2", pos1, pos2),
            (neg|gt, ":var_2", 1000),
            (val_add, "$tutorial_5_state", 1),
            (entry_point_get_position, pos1, 6),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_red", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
        (else_try),
            (eq, "$tutorial_5_state", 1),
            (try_begin),
                (eq, "$tutorial_5_msg_2_displayed", 0),
                (assign, "$tutorial_5_msg_2_displayed", 1),
                (tutorial_message, "str_tutorial_5_msg_2"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", 0, 0),
            (entry_point_get_position, pos2, 5),
            (get_distance_between_positions, ":var_2", pos1, pos2),
            (neg|gt, ":var_2", 1000),
            (get_player_agent_no, ":var_3"),
            (agent_get_position, pos1, ":var_3"),
            (entry_point_get_position, pos2, 6),
            (get_distance_between_positions, ":var_2", pos1, pos2),
            (neg|gt, ":var_2", 500),
            (val_add, "$tutorial_5_state", 1),
            (entry_point_get_position, pos1, 7),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
            (entry_point_get_position, pos1, 30),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_red", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
        (else_try),
            (eq, "$tutorial_5_state", 2),
            (try_begin),
                (eq, "$tutorial_5_msg_3_displayed", 0),
                (assign, "$tutorial_5_msg_3_displayed", 1),
                (tutorial_message, "str_tutorial_5_msg_3"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (get_player_agent_no, ":var_3"),
            (agent_get_position, pos1, ":var_3"),
            (entry_point_get_position, pos2, 7),
            (get_distance_between_positions, ":var_2", pos1, pos2),
            (neg|gt, ":var_2", 500),
            (val_add, "$tutorial_5_state", 1),
            (modify_visitors_at_site, "scn_tutorial_5"),
            (reset_visitors),
            (set_visitor, 5, "trp_rav_archer"),
            (set_visitor, 6, "trp_rav_archer"),
            (set_visitor, 7, "trp_rav_archer"),
            (entry_point_get_position, pos1, 11),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
            (entry_point_get_position, pos1, 12),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_red", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
            (set_show_messages, 0),
            (team_give_order, 0, 1, 11),
            (set_show_messages, 1),
        (else_try),
            (eq, "$tutorial_5_state", 3),
            (try_begin),
                (eq, "$tutorial_5_msg_4_displayed", 0),
                (assign, "$tutorial_5_msg_4_displayed", 1),
                (tutorial_message, "str_tutorial_5_msg_4"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", 0, 1),
            (entry_point_get_position, pos2, 11),
            (get_distance_between_positions, ":var_2", pos1, pos2),
            (neg|gt, ":var_2", 1000),
            (call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", 0, 0),
            (entry_point_get_position, pos2, 12),
            (get_distance_between_positions, ":var_2", pos1, pos2),
            (neg|gt, ":var_2", 1000),
            (val_add, "$tutorial_5_state", 1),
            (entry_point_get_position, pos1, 30),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_red", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
            (modify_visitors_at_site, "scn_tutorial_5"),
            (reset_visitors),
            (set_visitor, 8, "trp_bandit"),
            (set_visitor, 9, "trp_bandit"),
            (set_visitor, 10, "trp_bandit"),
            (set_visitor, 11, "trp_bandit"),
            (team_give_order, 1, 9, 2),
        (else_try),
            (eq, "$tutorial_5_state", 4),
            (try_begin),
                (eq, "$tutorial_5_msg_5_displayed", 0),
                (assign, "$tutorial_5_msg_5_displayed", 1),
                (tutorial_message, "str_tutorial_5_msg_5"),
                (play_sound, "snd_tutorial_1"),
            (try_end),
            (assign, ":var_4", 0),
            (try_for_agents, ":var_5"),
                (agent_is_human, ":var_5"),
                (agent_is_alive, ":var_5"),
                (agent_get_team, ":var_6", ":var_5"),
                (eq, ":var_6", 1),
                (val_add, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 0),
            (val_add, "$tutorial_5_state", 1),
        (else_try),
            (eq, "$tutorial_5_state", 5),
            (eq, "$tutorial_5_msg_6_displayed", 0),
            (assign, "$tutorial_5_msg_6_displayed", 1),
            (tutorial_message, "str_tutorial_5_msg_6"),
            (play_sound, "snd_tutorial_2"),
            (assign, "$tutorial_5_finished", 1),
        (else_try),
            (gt, "$tutorial_5_state", 30),
            (tutorial_message, "str_tutorial_failed"),
            (entry_point_get_position, pos1, 30),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_yellow", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
            (scene_prop_get_instance, ":var_1", "spr_tutorial_flag_red", 0),
            (prop_instance_animate_to_position, ":var_1", 1, 1),
        (try_end),
    ],
    [
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"quick_battle_battle", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|eq, "$g_battle_result", 0),
            (call_script, "script_custom_battle_end"),
            (finish_mission),
        (else_try),
            (question_box, "str_give_up_fight"),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$g_battle_result", -1),
        (call_script, "script_custom_battle_end"),
        (finish_mission),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (scene_set_day_time, 15),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_result", 0),
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 2),
        (neg|main_hero_fallen, 0),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
    ],
    [
        (call_script, "script_custom_battle_end"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (assign, "$g_battle_result", -1),
    ],
    [
        (call_script, "script_custom_battle_end"),
        (finish_mission),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"quick_battle_siege", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(16, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(17, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(18, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(19, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(20, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(21, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(22, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(23, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(24, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(25, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(26, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(27, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(28, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(29, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(30, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(31, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(32, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(33, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(34, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(35, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(36, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(37, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(38, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(39, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(40, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(41, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(42, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(43, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(44, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(45, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(46, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
(47, mtef_visitor_source|mtef_team_0, af_override_horse, 16, 1, []),
],
[
    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (team_set_relation, 0, 2, 1),
        (team_set_relation, 1, 3, 1),
        (call_script, "script_change_banners_and_chest"),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (assign, "$defender_team", 0),
        (assign, "$attacker_team", 1),
        (assign, "$defender_team_2", 2),
        (assign, "$attacker_team_2", 3),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (scene_set_day_time, 15),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (neg|eq, "$g_battle_result", 0),
            (call_script, "script_custom_battle_end"),
            (finish_mission),
        (else_try),
            (question_box, "str_give_up_fight"),
        (try_end),
    ]),

    (ti_question_answered, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (eq, ":var_0", 0),
        (assign, "$g_battle_result", -1),
        (call_script, "script_custom_battle_end"),
        (finish_mission),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$g_battle_result", 0),
        (call_script, "script_music_set_situation_with_culture", 262144),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_combat_music_set_situation_with_culture"),
    ]),

    (1.000000, 60.000000, ti_once, 
    [
        (store_mission_timer_a, reg1),
        (ge, reg1, 10),
        (all_enemies_defeated, 2),
        (neg|main_hero_fallen, 0),
        (set_mission_result, 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
        (assign, "$g_battle_won", 1),
        (assign, "$g_battle_result", 1),
    ],
    [
        (call_script, "script_custom_battle_end"),
        (finish_mission, 1),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (eq, "$g_battle_won", 1),
        (call_script, "script_victory_message"),
        (display_message, "@{s37}"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (main_hero_fallen),
        (assign, "$g_battle_result", -1),
    ],
    [
        (call_script, "script_custom_battle_end"),
        (finish_mission),
    ]),

    (5.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_team, ":var_1", ":var_0"),
            (this_or_next|eq, ":var_1", "$attacker_team"),
            (eq, ":var_1", "$attacker_team_2"),
            (agent_ai_set_always_attack_in_melee, ":var_0", 1),
        (try_end),
    ]),

    (60.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (this_or_next|eq, ":var_2", "$defender_team"),
            (eq, ":var_2", "$defender_team_2"),
            (agent_refill_ammo, ":var_1"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (call_script, "script_siege_init_ai_and_belfry"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (call_script, "script_cf_siege_move_belfry"),
    ],
    [
    ]),

    (0.000000, 2.000000, ti_once, 
    [
        (call_script, "script_cf_siege_rotate_belfry_platform"),
    ],
    [
        (assign, "$belfry_positioned", 3),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (call_script, "script_cf_siege_assign_men_to_belfry"),
    ],
    [
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (set_show_messages, 0),
        (entry_point_get_position, pos10, 10),
        (try_for_range, ":var_0", 0, 9),
            (neg|eq, ":var_0", 1),
            (team_give_order, "$defender_team", ":var_0", 0),
            (team_give_order, "$defender_team", ":var_0", 7),
            (team_give_order, "$defender_team", ":var_0", 7),
            (team_give_order, "$defender_team_2", ":var_0", 0),
            (team_give_order, "$defender_team_2", ":var_0", 7),
            (team_give_order, "$defender_team_2", ":var_0", 7),
        (try_end),
        (team_give_order, "$defender_team", 1, 11),
        (team_set_order_position, "$defender_team", 9, pos10),
        (team_give_order, "$defender_team_2", 1, 11),
        (team_set_order_position, "$defender_team_2", 9, pos10),
        (set_show_messages, 1),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"multiplayer_dm", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 0),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (multiplayer_make_everyone_enemy),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (multiplayer_get_my_player, ":var_0"),
            (is_between, ":var_0", 0, 1000),
            (player_get_team_no, ":var_1", ":var_0"),
            (neg|ge, ":var_1", 2),
            (player_get_kill_count, ":var_2", ":var_0"),
            (player_get_death_count, ":var_3", ":var_0"),
            (store_mul, ":var_4", ":var_2", 1000),
            (val_sub, ":var_4", ":var_3"),
            (assign, ":var_5", 1),
            (get_max_players, ":var_6"),
            (assign, ":var_7", ":var_6"),
            (try_for_range, ":var_8", 0, ":var_7"),
                (player_is_active, ":var_8"),
                (player_get_team_no, ":var_9", ":var_8"),
                (this_or_next|eq, ":var_9", 0),
                (eq, ":var_9", 1),
                (player_get_kill_count, ":var_2", ":var_8"),
                (player_get_death_count, ":var_3", ":var_8"),
                (store_mul, ":var_10", ":var_2", 1000),
                (val_sub, ":var_10", ":var_3"),
                (gt, ":var_10", ":var_4"),
                (assign, ":var_5", 0),
                (assign, ":var_7", 0),
            (try_end),
            (eq, ":var_5", 1),
            (unlock_achievement, 68),
        (try_end),
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart_deathmatch"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (player_get_team_no, ":var_2", ":var_1"),
            (neg|ge, ":var_2", 2),
            (player_get_troop_id, ":var_3", ":var_1"),
            (ge, ":var_3", 0),
            (player_get_agent_id, ":var_4", ":var_1"),
            (assign, ":var_5", 0),
            (try_begin),
                (player_get_slot, ":var_6", ":var_1", 24),
                (eq, ":var_6", 1),
                (assign, ":var_5", 1),
                (player_set_slot, ":var_1", 24, 0),
            (else_try),
                (try_begin),
                    (neg|ge, ":var_4", 0),
                    (assign, ":var_5", 1),
                (else_try),
                    (neg|agent_is_alive, ":var_4"),
                    (agent_get_time_elapsed_since_removed, ":var_7", ":var_4"),
                    (gt, ":var_7", "$g_multiplayer_respawn_period"),
                    (assign, ":var_5", 1),
                (try_end),
            (try_end),
            (eq, ":var_5", 1),
            (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
            (troop_get_inventory_slot, ":var_8", ":var_3", 8),
            (try_begin),
                (ge, ":var_8", 0),
                (assign, ":var_9", 1),
            (else_try),
                (assign, ":var_9", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_9"),
            (player_spawn_new_agent, ":var_1", reg0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (try_for_agents, ":var_3"),
            (agent_is_non_player, ":var_3"),
            (agent_is_human, ":var_3"),
            (assign, ":var_4", 0),
            (try_begin),
                (agent_is_alive, ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (agent_get_time_elapsed_since_removed, ":var_5", ":var_3"),
                (neg|gt, ":var_5", "$g_multiplayer_respawn_period"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (agent_get_team, ":var_6", ":var_3"),
            (try_begin),
                (eq, ":var_6", 0),
                (val_add, ":var_1", 1),
            (else_try),
                (eq, ":var_6", 1),
                (val_add, ":var_2", 1),
            (try_end),
        (try_end),
        (store_sub, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1", ":var_1"),
        (store_sub, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2", ":var_2"),
        (val_max, "$g_multiplayer_num_bots_required_team_1", 0),
        (val_max, "$g_multiplayer_num_bots_required_team_2", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (store_random_in_range, ":var_1", 0, ":var_0"),
            (val_sub, ":var_1", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_2", 0),
                (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
            (else_try),
                (assign, ":var_2", 1),
                (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
            (try_end),
            (team_get_faction, ":var_3", ":var_2"),
            (assign, ":var_4", 0),
            (try_for_range, ":var_5", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_6", ":var_5"),
                (eq, ":var_6", ":var_3"),
                (val_add, ":var_4", 1),
            (try_end),
            (store_random_in_range, ":var_7", 0, ":var_4"),
            (assign, ":var_8", "trp_sarleon_longbowman_multiplayer"),
            (try_for_range, ":var_5", "trp_sarleon_longbowman_multiplayer_ai", ":var_8"),
                (store_troop_faction, ":var_6", ":var_5"),
                (eq, ":var_6", ":var_3"),
                (val_sub, ":var_7", 1),
                (neg|ge, ":var_7", 0),
                (assign, ":var_8", 0),
                (assign, ":var_9", ":var_5"),
            (try_end),
            (troop_get_inventory_slot, ":var_10", ":var_9", 8),
            (try_begin),
                (ge, ":var_10", 0),
                (assign, ":var_11", 1),
            (else_try),
                (assign, ":var_11", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_11"),
            (store_current_scene, ":var_12"),
            (modify_visitors_at_site, ":var_12"),
            (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_2", -1),
            (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (store_mission_timer_a, ":var_1"),
            (store_mul, ":var_2", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_1", ":var_2"),
            (assign, ":var_0", 1),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart_deathmatch"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart_deathmatch"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"multiplayer_tdm", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 1),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (multiplayer_get_my_player, ":var_0"),
            (is_between, ":var_0", 0, 1000),
            (player_get_team_no, ":var_1", ":var_0"),
            (neg|ge, ":var_1", 2),
            (team_get_score, ":var_2", 0),
            (team_get_score, ":var_3", 1),
            (assign, ":var_4", 0),
            (try_begin),
                (eq, ":var_1", 0),
                (gt, ":var_2", ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (eq, ":var_1", 1),
                (gt, ":var_3", ":var_2"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (unlock_achievement, 67),
        (try_end),
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (ge, ":var_1", 0),
            (agent_is_human, ":var_0"),
            (agent_is_human, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (neg|gt, ":var_2", 1),
            (agent_get_team, ":var_3", ":var_0"),
            (neg|eq, ":var_2", ":var_3"),
            (team_get_score, ":var_4", ":var_2"),
            (val_add, ":var_4", 1),
            (team_set_score, ":var_2", ":var_4"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (player_get_team_no, ":var_2", ":var_1"),
            (neg|ge, ":var_2", 2),
            (player_get_troop_id, ":var_3", ":var_1"),
            (ge, ":var_3", 0),
            (player_get_agent_id, ":var_4", ":var_1"),
            (assign, ":var_5", 0),
            (try_begin),
                (player_get_slot, ":var_6", ":var_1", 24),
                (eq, ":var_6", 1),
                (assign, ":var_5", 1),
                (player_set_slot, ":var_1", 24, 0),
            (else_try),
                (try_begin),
                    (neg|ge, ":var_4", 0),
                    (assign, ":var_5", 1),
                (else_try),
                    (neg|agent_is_alive, ":var_4"),
                    (agent_get_time_elapsed_since_removed, ":var_7", ":var_4"),
                    (gt, ":var_7", "$g_multiplayer_respawn_period"),
                    (assign, ":var_5", 1),
                (try_end),
            (try_end),
            (eq, ":var_5", 1),
            (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
            (troop_get_inventory_slot, ":var_8", ":var_3", 8),
            (try_begin),
                (ge, ":var_8", 0),
                (assign, ":var_9", 1),
            (else_try),
                (assign, ":var_9", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 1, ":var_9"),
            (player_spawn_new_agent, ":var_1", reg0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (try_for_agents, ":var_3"),
            (agent_is_non_player, ":var_3"),
            (agent_is_human, ":var_3"),
            (assign, ":var_4", 0),
            (try_begin),
                (agent_is_alive, ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (agent_get_time_elapsed_since_removed, ":var_5", ":var_3"),
                (neg|gt, ":var_5", "$g_multiplayer_respawn_period"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (agent_get_team, ":var_6", ":var_3"),
            (try_begin),
                (eq, ":var_6", 0),
                (val_add, ":var_1", 1),
            (else_try),
                (eq, ":var_6", 1),
                (val_add, ":var_2", 1),
            (try_end),
        (try_end),
        (store_sub, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1", ":var_1"),
        (store_sub, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2", ":var_2"),
        (val_max, "$g_multiplayer_num_bots_required_team_1", 0),
        (val_max, "$g_multiplayer_num_bots_required_team_2", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (this_or_next|eq, "$g_multiplayer_game_type", 3),
                (eq, "$g_multiplayer_game_type", 6),
                (team_get_score, ":var_1", 0),
                (team_get_score, ":var_2", 1),
                (store_add, ":var_3", ":var_1", ":var_2"),
                (eq, ":var_3", 0),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (neg|ge, ":var_4", 20),
                (assign, ":var_5", 0),
            (else_try),
                (assign, ":var_5", 1),
            (try_end),
            (eq, ":var_5", 1),
            (store_random_in_range, ":var_6", 0, ":var_0"),
            (val_sub, ":var_6", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_6", 0),
                (assign, ":var_7", 0),
            (else_try),
                (assign, ":var_7", 1),
            (try_end),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (eq, "$g_multiplayer_game_type", 3),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (try_begin),
                    (neg|gt, ":var_4", 20),
                    (assign, ":var_8", 0),
                (else_try),
                    (assign, ":var_8", 1),
                (try_end),
            (else_try),
                (assign, ":var_8", 1),
            (try_end),
            (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":var_7", ":var_8"),
            (assign, ":var_9", reg0),
            (assign, ":var_10", reg1),
            (team_get_faction, ":var_11", ":var_7"),
            (assign, ":var_12", 0),
            (try_for_range, ":var_13", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_14", ":var_13"),
                (eq, ":var_14", ":var_11"),
                (val_add, ":var_12", 1),
            (try_end),
            (assign, ":var_15", 0),
            (get_max_players, ":var_16"),
            (try_for_range, ":var_17", 0, ":var_16"),
                (player_is_active, ":var_17"),
                (player_get_team_no, ":var_18", ":var_17"),
                (eq, ":var_7", ":var_18"),
                (assign, ":var_19", 0),
                (store_add, ":var_20", 35, ":var_12"),
                (try_for_range, ":var_21", 35, ":var_20"),
                    (player_slot_ge, ":var_17", ":var_21", 1),
                    (assign, ":var_19", 1),
                    (assign, ":var_20", 0),
                (try_end),
                (ge, ":var_19", 1),
                (val_add, ":var_15", 1),
            (try_end),
            (try_begin),
                (this_or_next|ge, ":var_10", 0),
                (eq, ":var_15", 0),
                (troop_get_inventory_slot, ":var_22", ":var_9", 8),
                (try_begin),
                    (ge, ":var_22", 0),
                    (assign, ":var_23", 1),
                (else_try),
                    (assign, ":var_23", 0),
                (try_end),
                (try_begin),
                    (eq, "$g_multiplayer_game_type", 6),
                    (store_mission_timer_a, ":var_4"),
                    (val_sub, ":var_4", "$g_round_start_time"),
                    (try_begin),
                        (neg|ge, ":var_4", 20),
                        (try_begin),
                            (eq, ":var_7", 0),
                            (call_script, "script_multiplayer_find_spawn_point", ":var_7", 1, ":var_23"),
                        (else_try),
                            (assign, reg0, 32),
                        (try_end),
                    (else_try),
                        (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                    (try_end),
                (else_try),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, reg0, 0),
                    (else_try),
                        (assign, reg0, 32),
                    (try_end),
                (else_try),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                (try_end),
                (store_current_scene, ":var_24"),
                (modify_visitors_at_site, ":var_24"),
                (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_7", ":var_10"),
                (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
                (try_begin),
                    (eq, ":var_7", 0),
                    (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
                (else_try),
                    (eq, ":var_7", 1),
                    (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_agents, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_group, ":var_1", ":var_0"),
            (try_begin),
                (neg|player_is_active, ":var_1"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (else_try),
                (player_get_team_no, ":var_2", ":var_1"),
                (agent_get_team, ":var_3", ":var_0"),
                (neg|eq, ":var_2", ":var_3"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (try_end),
        (try_end),
    ]),

    (20.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (call_script, "script_check_team_balance"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_game_type", 2),
            (this_or_next|eq, "$g_multiplayer_game_type", 3),
            (eq, "$g_multiplayer_game_type", 6),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (store_mission_timer_a, ":var_1"),
                (val_sub, ":var_1", "$g_round_finish_time"),
                (store_sub, ":var_2", "$g_multiplayer_respawn_period", 1),
                (ge, ":var_1", ":var_2"),
                (store_mission_timer_a, ":var_3"),
                (try_begin),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (assign, ":var_4", 90),
                (else_try),
                    (assign, ":var_4", 120),
                (try_end),
                (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (gt, ":var_3", ":var_6"),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 1),
        (else_try),
            (neg|eq, "$g_multiplayer_game_type", 2),
            (neg|eq, "$g_multiplayer_game_type", 3),
            (neg|eq, "$g_multiplayer_game_type", 6),
            (neg|eq, "$g_multiplayer_game_type", 5),
            (store_mission_timer_a, ":var_3"),
            (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_3", ":var_5"),
            (assign, ":var_0", 1),
        (else_try),
            (team_get_score, ":var_7", 0),
            (team_get_score, ":var_8", 1),
            (try_begin),
                (neg|eq, "$g_multiplayer_game_type", 5),
                (try_begin),
                    (this_or_next|ge, ":var_7", "$g_multiplayer_game_max_points"),
                    (ge, ":var_8", "$g_multiplayer_game_max_points"),
                    (assign, ":var_0", 1),
                (try_end),
            (else_try),
                (assign, ":var_9", 0),
                (get_max_players, ":var_10"),
                (try_for_range, ":var_11", 0, ":var_10"),
                    (player_is_active, ":var_11"),
                    (player_get_agent_id, ":var_12", ":var_11"),
                    (ge, ":var_12", 0),
                    (neg|agent_is_non_player, ":var_12"),
                    (assign, ":var_9", 1),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_9", 1),
                (this_or_next|neg|gt, ":var_7", 0),
                (neg|gt, ":var_8", 0),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_team_score_display"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"multiplayer_hq", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 5),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (store_mul, ":var_0", "$g_multiplayer_game_max_points", 10000),
        (assign, "$g_score_team_1", ":var_0"),
        (assign, "$g_score_team_2", ":var_0"),
        (try_for_range, ":var_1", 146, 156),
            (troop_set_slot, "trp_multiplayer_data", ":var_1", -1),
        (try_end),
        (try_begin),
            (multiplayer_is_server),
            (try_for_range, ":var_1", 176, 186),
                (troop_set_slot, "trp_multiplayer_data", ":var_1", -1),
            (try_end),
        (try_end),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (try_begin),
            (multiplayer_is_server),
            (team_set_score, 0, "$g_multiplayer_game_max_points"),
            (team_set_score, 1, "$g_multiplayer_game_max_points"),
        (try_end),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_determine_team_flags", 0),
        (call_script, "script_determine_team_flags", 1),
        (set_spawn_effector_scene_prop_kind, 0, "$team_1_flag_scene_prop"),
        (set_spawn_effector_scene_prop_kind, 1, "$team_2_flag_scene_prop"),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
            (assign, "$g_number_of_flags", 0),
            (entry_point_get_position, pos1, 64),
            (entry_point_get_position, pos3, 64),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "spr_headquarters_pole_code_only", 0),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "$team_1_flag_scene_prop", 0),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "$team_2_flag_scene_prop", 0),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "spr_headquarters_flag_gray_code_only", 0),
            (store_add, ":var_0", 146, "$g_number_of_flags"),
            (troop_set_slot, "trp_multiplayer_data", ":var_0", 1),
            (val_add, "$g_number_of_flags", 1),
            (entry_point_get_position, pos2, 65),
            (entry_point_get_position, pos3, 65),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "spr_headquarters_pole_code_only", 0),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "$team_1_flag_scene_prop", 0),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "$team_2_flag_scene_prop", 0),
            (set_spawn_position, pos3),
            (spawn_scene_prop, "spr_headquarters_flag_gray_code_only", 0),
            (store_add, ":var_0", 146, "$g_number_of_flags"),
            (troop_set_slot, "trp_multiplayer_data", ":var_0", 2),
            (val_add, "$g_number_of_flags", 1),
            (scene_prop_get_num_instances, ":var_1", "spr_headquarters_flag_red"),
            (scene_prop_get_num_instances, ":var_2", "spr_headquarters_flag_blue"),
            (scene_prop_get_num_instances, ":var_3", "spr_headquarters_flag_gray"),
            (store_add, ":var_4", "spr_headquarters_flag_gray", 1),
            (try_for_range, ":var_5", "spr_headquarters_flag_red", ":var_4"),
                (try_begin),
                    (eq, ":var_5", "spr_headquarters_flag_red"),
                    (assign, ":var_6", ":var_1"),
                (else_try),
                    (eq, ":var_5", "spr_headquarters_flag_blue"),
                    (assign, ":var_6", ":var_2"),
                (else_try),
                    (eq, ":var_5", "spr_headquarters_flag_gray"),
                    (assign, ":var_6", ":var_3"),
                (try_end),
                (gt, ":var_6", 0),
                (try_for_range, ":var_7", 0, ":var_6"),
                    (scene_prop_get_instance, ":var_8", ":var_5", ":var_7"),
                    (prop_instance_get_position, pos0, ":var_8"),
                    (set_spawn_position, pos0),
                    (spawn_scene_prop, "spr_headquarters_pole_code_only", 0),
                    (try_for_range, ":var_9", "spr_headquarters_flag_red", ":var_4"),
                        (set_spawn_position, pos0),
                        (try_begin),
                            (eq, ":var_9", "spr_headquarters_flag_red"),
                            (spawn_scene_prop, "$team_1_flag_scene_prop"),
                        (else_try),
                            (eq, ":var_9", "spr_headquarters_flag_blue"),
                            (spawn_scene_prop, "$team_2_flag_scene_prop"),
                        (else_try),
                            (eq, ":var_9", "spr_headquarters_flag_gray"),
                            (spawn_scene_prop, "spr_headquarters_flag_gray_code_only"),
                        (try_end),
                    (try_end),
                    (store_add, ":var_0", 146, "$g_number_of_flags"),
                    (try_begin),
                        (eq, ":var_5", "spr_headquarters_flag_red"),
                        (troop_set_slot, "trp_multiplayer_data", ":var_0", 1),
                    (else_try),
                        (eq, ":var_5", "spr_headquarters_flag_blue"),
                        (troop_set_slot, "trp_multiplayer_data", ":var_0", 2),
                    (else_try),
                        (eq, ":var_5", "spr_headquarters_flag_gray"),
                        (troop_set_slot, "trp_multiplayer_data", ":var_0", 0),
                    (try_end),
                    (val_add, "$g_number_of_flags", 1),
                (try_end),
            (try_end),
            (assign, "$g_number_of_initial_team_1_flags", 0),
            (assign, "$g_number_of_initial_team_2_flags", 0),
            (try_for_range, ":var_10", 0, "$g_number_of_flags"),
                (store_add, ":var_0", 146, ":var_10"),
                (troop_get_slot, ":var_11", "trp_multiplayer_data", ":var_0"),
                (try_begin),
                    (eq, ":var_10", 0),
                    (entry_point_get_position, pos0, 64),
                    (scene_prop_get_instance, ":var_8", "$team_1_flag_scene_prop", ":var_10"),
                    (assign, "$g_base_flag_team_1", ":var_8"),
                (else_try),
                    (eq, ":var_10", 1),
                    (entry_point_get_position, pos0, 65),
                    (scene_prop_get_instance, ":var_8", "$team_2_flag_scene_prop", ":var_10"),
                    (assign, "$g_base_flag_team_2", ":var_8"),
                (else_try),
                    (assign, ":var_12", 2),
                    (scene_prop_get_num_instances, ":var_13", "spr_headquarters_flag_red"),
                    (store_add, ":var_14", ":var_12", ":var_13"),
                    (scene_prop_get_num_instances, ":var_15", "spr_headquarters_flag_blue"),
                    (store_add, ":var_16", ":var_14", ":var_15"),
                    (scene_prop_get_num_instances, ":var_17", "spr_headquarters_flag_gray"),
                    (try_begin),
                        (ge, ":var_10", ":var_12"),
                        (gt, ":var_13", 0),
                        (store_sub, ":var_18", ":var_10", ":var_12"),
                        (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_red", ":var_18"),
                    (else_try),
                        (ge, ":var_10", ":var_14"),
                        (gt, ":var_15", 0),
                        (store_sub, ":var_18", ":var_10", ":var_14"),
                        (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_blue", ":var_18"),
                    (else_try),
                        (ge, ":var_10", ":var_16"),
                        (gt, ":var_17", 0),
                        (store_sub, ":var_18", ":var_10", ":var_16"),
                        (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_gray", ":var_18"),
                    (try_end),
                    (prop_instance_get_position, pos0, ":var_8"),
                (try_end),
                (scene_prop_get_instance, ":var_19", "spr_headquarters_pole_code_only", ":var_10"),
                (prop_instance_set_position, ":var_19", pos0),
                (position_move_z, pos0, 900),
                (try_begin),
                    (eq, ":var_11", 0),
                    (scene_prop_get_instance, ":var_8", "$team_1_flag_scene_prop", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 0),
                    (scene_prop_get_instance, ":var_8", "$team_2_flag_scene_prop", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 0),
                    (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_gray_code_only", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 1),
                (else_try),
                    (eq, ":var_11", 1),
                    (scene_prop_get_instance, ":var_8", "$team_1_flag_scene_prop", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 1),
                    (scene_prop_get_instance, ":var_8", "$team_2_flag_scene_prop", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 0),
                    (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_gray_code_only", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 0),
                    (val_add, "$g_number_of_initial_team_1_flags", 1),
                (else_try),
                    (scene_prop_get_instance, ":var_8", "$team_1_flag_scene_prop", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 0),
                    (scene_prop_get_instance, ":var_8", "$team_2_flag_scene_prop", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 1),
                    (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_gray_code_only", ":var_10"),
                    (prop_instance_set_position, ":var_8", pos0),
                    (scene_prop_set_visibility, ":var_8", 0),
                    (val_add, "$g_number_of_initial_team_2_flags", 1),
                (try_end),
            (try_end),
        (else_try),
            (scene_prop_get_num_instances, ":var_1", "spr_headquarters_flag_red"),
            (scene_prop_get_num_instances, ":var_2", "spr_headquarters_flag_blue"),
            (scene_prop_get_num_instances, ":var_3", "spr_headquarters_flag_gray"),
            (assign, "$g_number_of_flags", 2),
            (val_add, "$g_number_of_flags", ":var_1"),
            (val_add, "$g_number_of_flags", ":var_2"),
            (val_add, "$g_number_of_flags", ":var_3"),
        (try_end),
        (try_for_range, ":var_18", 0, ":var_1"),
            (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_red", ":var_18"),
            (scene_prop_set_visibility, ":var_8", 0),
        (try_end),
        (try_for_range, ":var_18", 0, ":var_2"),
            (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_blue", ":var_18"),
            (scene_prop_set_visibility, ":var_8", 0),
        (try_end),
        (try_for_range, ":var_18", 0, ":var_3"),
            (scene_prop_get_instance, ":var_8", "spr_headquarters_flag_gray", ":var_18"),
            (scene_prop_set_visibility, ":var_8", 0),
        (try_end),
        (try_for_range, ":var_18", 0, "$g_number_of_flags"),
            (store_add, ":var_20", 166, ":var_18"),
            (troop_set_slot, "trp_multiplayer_data", ":var_20", 0),
        (try_end),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (multiplayer_get_my_player, ":var_0"),
            (is_between, ":var_0", 0, 1000),
            (player_get_team_no, ":var_1", ":var_0"),
            (neg|ge, ":var_1", 2),
            (call_script, "script_get_headquarters_scores"),
            (assign, ":var_2", reg0),
            (assign, ":var_3", reg1),
            (assign, ":var_4", 0),
            (try_begin),
                (eq, ":var_1", 0),
                (gt, ":var_2", ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (eq, ":var_1", 1),
                (gt, ":var_3", ":var_2"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (unlock_achievement, 61),
        (try_end),
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (multiplayer_is_server),
            (ge, ":var_1", 0),
            (agent_is_human, ":var_0"),
            (agent_is_human, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (neg|gt, ":var_2", 1),
            (agent_get_team, ":var_3", ":var_0"),
            (neg|eq, ":var_2", ":var_3"),
            (team_get_score, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_2", 0),
                (val_add, "$g_score_team_2", -10000),
            (else_try),
                (val_add, "$g_score_team_1", -10000),
            (try_end),
            (val_sub, ":var_4", 1),
            (get_max_players, ":var_5"),
            (call_script, "script_team_set_score", ":var_3", ":var_4"),
            (try_for_range, ":var_6", 1, ":var_5"),
                (player_is_active, ":var_6"),
                (multiplayer_send_2_int_to_player, ":var_6", 72, ":var_3", ":var_4"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_range, ":var_0", 0, "$g_number_of_flags"),
            (store_add, ":var_1", 166, ":var_0"),
            (troop_get_slot, ":var_2", "trp_multiplayer_data", ":var_1"),
            (val_add, ":var_2", 1),
            (troop_set_slot, "trp_multiplayer_data", ":var_1", ":var_2"),
            (store_add, ":var_3", 176, ":var_0"),
            (troop_get_slot, ":var_4", "trp_multiplayer_data", ":var_3"),
            (store_mod, ":var_5", ":var_4", 100),
            (try_begin),
                (ge, ":var_4", 100),
                (neg|ge, ":var_5", 25),
                (val_add, ":var_4", 1),
                (troop_set_slot, "trp_multiplayer_data", ":var_3", ":var_4"),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_range, ":var_0", 0, "$g_number_of_flags"),
            (store_add, ":var_1", 156, ":var_0"),
            (troop_get_slot, ":var_2", "trp_multiplayer_data", ":var_1"),
            (store_div, ":var_3", ":var_2", 100),
            (store_mod, ":var_4", ":var_2", 100),
            (assign, ":var_5", 0),
            (assign, ":var_6", 0),
            (scene_prop_get_instance, ":var_7", "spr_headquarters_pole_code_only", ":var_0"),
            (prop_instance_get_position, pos0, ":var_7"),
            (get_max_players, ":var_8"),
            (try_for_range, ":var_9", 0, ":var_8"),
                (player_is_active, ":var_9"),
                (player_get_agent_id, ":var_10", ":var_9"),
                (ge, ":var_10", 0),
                (agent_is_alive, ":var_10"),
                (agent_get_team, ":var_11", ":var_10"),
                (agent_get_position, pos1, ":var_10"),
                (get_sq_distance_between_positions, ":var_12", pos0, pos1),
                (get_sq_distance_between_position_heights, ":var_13", pos0, pos1),
                (val_add, ":var_12", ":var_13"),
                (neg|ge, ":var_12", 1600),
                (try_begin),
                    (eq, ":var_11", 0),
                    (val_add, ":var_5", 1),
                (else_try),
                    (eq, ":var_11", 1),
                    (val_add, ":var_6", 1),
                (try_end),
            (try_end),
            (try_begin),
                (this_or_next|neg|eq, ":var_3", ":var_5"),
                (neg|eq, ":var_4", ":var_6"),
                (store_add, ":var_14", 146, ":var_0"),
                (troop_get_slot, ":var_15", "trp_multiplayer_data", ":var_14"),
                (store_add, ":var_16", 176, ":var_0"),
                (troop_get_slot, ":var_17", "trp_multiplayer_data", ":var_16"),
                (store_mod, ":var_18", ":var_17", 100),
                (store_div, ":var_19", ":var_17", 100),
                (try_begin),
                    (assign, ":var_20", 0),
                    (try_begin),
                        (neg|eq, ":var_15", 1),
                        (eq, ":var_3", 0),
                        (gt, ":var_5", 0),
                        (eq, ":var_6", 0),
                        (assign, ":var_21", 1),
                        (assign, ":var_20", 1),
                    (else_try),
                        (neg|eq, ":var_15", 2),
                        (eq, ":var_4", 0),
                        (eq, ":var_5", 0),
                        (gt, ":var_6", 0),
                        (assign, ":var_21", 2),
                        (assign, ":var_20", 1),
                    (try_end),
                    (eq, ":var_20", 1),
                    (store_mul, ":var_22", ":var_21", 100),
                    (troop_set_slot, "trp_multiplayer_data", ":var_16", ":var_22"),
                    (this_or_next|neg|eq, ":var_19", ":var_21"),
                    (ge, ":var_18", 25),
                    (store_mul, ":var_23", ":var_21", 100),
                    (val_add, ":var_23", ":var_0"),
                    (call_script, "script_show_multiplayer_message", 10, ":var_23"),
                    (try_for_range, ":var_9", 1, ":var_8"),
                        (player_is_active, ":var_9"),
                        (multiplayer_send_2_int_to_player, ":var_9", 68, 10, ":var_23"),
                    (try_end),
                (try_end),
                (try_begin),
                    (store_mul, ":var_2", ":var_5", 100),
                    (val_add, ":var_2", ":var_6"),
                    (troop_set_slot, "trp_multiplayer_data", ":var_1", ":var_2"),
                    (call_script, "script_set_num_agents_around_flag", ":var_0", ":var_2"),
                    (get_max_players, ":var_8"),
                    (try_for_range, ":var_9", 1, ":var_8"),
                        (player_is_active, ":var_9"),
                        (multiplayer_send_2_int_to_player, ":var_9", 73, ":var_0", ":var_2"),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_for_range, ":var_0", 0, "$g_number_of_flags"),
            (assign, ":var_24", -1),
            (scene_prop_get_instance, ":var_7", "spr_headquarters_pole_code_only", ":var_0"),
            (prop_instance_get_position, pos0, ":var_7"),
            (store_add, ":var_14", 146, ":var_0"),
            (troop_get_slot, ":var_15", "trp_multiplayer_data", ":var_14"),
            (try_begin),
                (try_begin),
                    (scene_prop_get_instance, ":var_25", "$team_1_flag_scene_prop", ":var_0"),
                    (scene_prop_get_visibility, ":var_26", ":var_25"),
                    (assign, ":var_27", 1),
                    (eq, ":var_26", 0),
                    (scene_prop_get_instance, ":var_25", "$team_2_flag_scene_prop", ":var_0"),
                    (scene_prop_get_visibility, ":var_26", ":var_25"),
                    (assign, ":var_27", 2),
                    (eq, ":var_26", 0),
                    (scene_prop_get_instance, ":var_25", "spr_headquarters_flag_gray_code_only", ":var_0"),
                    (scene_prop_get_visibility, ":var_26", ":var_25"),
                    (assign, ":var_27", 0),
                (try_end),
                (prop_instance_get_position, pos1, ":var_25"),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_12", pos0, pos1),
                    (neg|ge, ":var_12", 400),
                    (store_add, ":var_28", 156, ":var_0"),
                    (troop_get_slot, ":var_29", "trp_multiplayer_data", ":var_28"),
                    (store_div, ":var_5", ":var_29", 100),
                    (store_mod, ":var_6", ":var_29", 100),
                    (try_begin),
                        (gt, ":var_5", 0),
                        (eq, ":var_6", 0),
                        (assign, ":var_24", 0),
                        (assign, ":var_30", 1),
                    (else_try),
                        (eq, ":var_5", 0),
                        (gt, ":var_6", 0),
                        (assign, ":var_24", 0),
                        (assign, ":var_30", 2),
                    (else_try),
                        (eq, ":var_5", 0),
                        (eq, ":var_6", 0),
                        (neg|eq, ":var_27", 0),
                        (assign, ":var_24", 0),
                        (assign, ":var_30", 0),
                    (try_end),
                (else_try),
                    (neg|eq, ":var_15", ":var_27"),
                    (get_sq_distance_between_positions, ":var_12", pos0, pos1),
                    (ge, ":var_12", 8100),
                    (store_add, ":var_28", 156, ":var_0"),
                    (troop_get_slot, ":var_29", "trp_multiplayer_data", ":var_28"),
                    (store_div, ":var_5", ":var_29", 100),
                    (store_mod, ":var_6", ":var_29", 100),
                    (try_begin),
                        (eq, ":var_27", 1),
                        (assign, ":var_24", 1),
                        (assign, ":var_30", 1),
                    (else_try),
                        (eq, ":var_27", 2),
                        (assign, ":var_24", 2),
                        (assign, ":var_30", 2),
                    (try_end),
                (try_end),
            (try_end),
            (try_begin),
                (ge, ":var_24", 0),
                (this_or_next|neg|eq, ":var_24", ":var_15"),
                (neg|eq, ":var_27", ":var_30"),
                (try_begin),
                    (neg|eq, ":var_15", 0),
                    (eq, ":var_24", 0),
                    (try_begin),
                        (eq, ":var_15", 1),
                        (assign, ":var_31", 2),
                    (else_try),
                        (eq, ":var_15", 2),
                        (assign, ":var_31", 1),
                    (try_end),
                    (store_mul, ":var_23", ":var_31", 100),
                    (val_add, ":var_23", ":var_0"),
                    (call_script, "script_show_multiplayer_message", 8, ":var_23"),
                    (get_max_players, ":var_8"),
                    (try_for_range, ":var_9", 1, ":var_8"),
                        (player_is_active, ":var_9"),
                        (multiplayer_send_2_int_to_player, ":var_9", 68, 8, ":var_23"),
                    (try_end),
                (try_end),
                (try_begin),
                    (neg|eq, ":var_15", ":var_24"),
                    (neg|eq, ":var_24", 0),
                    (store_mul, ":var_23", ":var_24", 100),
                    (val_add, ":var_23", ":var_0"),
                    (call_script, "script_show_multiplayer_message", 9, ":var_23"),
                    (get_max_players, ":var_8"),
                    (try_for_range, ":var_9", 1, ":var_8"),
                        (player_is_active, ":var_9"),
                        (multiplayer_send_2_int_to_player, ":var_9", 68, 9, ":var_23"),
                    (try_end),
                (try_end),
                (call_script, "script_set_num_agents_around_flag", ":var_0", ":var_29"),
                (assign, ":var_32", 0),
                (get_max_players, ":var_8"),
                (try_for_range, ":var_9", 1, ":var_8"),
                    (player_is_active, ":var_9"),
                    (multiplayer_send_2_int_to_player, ":var_9", 73, ":var_0", ":var_29"),
                    (val_add, ":var_32", 1),
                (try_end),
                (store_mul, ":var_33", ":var_24", 100),
                (val_add, ":var_33", ":var_30"),
                (call_script, "script_change_flag_owner", ":var_0", ":var_33"),
                (try_for_range, ":var_9", 1, ":var_8"),
                    (player_is_active, ":var_9"),
                    (multiplayer_send_2_int_to_player, ":var_9", 75, ":var_0", ":var_33"),
                (try_end),
                (try_begin),
                    (neg|eq, ":var_24", 0),
                    (try_begin),
                        (eq, ":var_24", 1),
                        (assign, ":var_34", ":var_5"),
                    (else_try),
                        (assign, ":var_34", ":var_6"),
                    (try_end),
                    (store_add, ":var_35", 166, ":var_0"),
                    (troop_get_slot, ":var_36", "trp_multiplayer_data", ":var_35"),
                    (troop_set_slot, "trp_multiplayer_data", ":var_35", 0),
                    (val_min, ":var_36", 360),
                    (scene_prop_get_instance, ":var_37", "$team_1_flag_scene_prop", ":var_0"),
                    (scene_prop_get_instance, ":var_38", "$team_2_flag_scene_prop", ":var_0"),
                    (try_begin),
                        (this_or_next|eq, "$g_base_flag_team_1", ":var_37"),
                        (eq, "$g_base_flag_team_2", ":var_38"),
                        (assign, ":var_39", 2),
                    (else_try),
                        (assign, ":var_39", 1),
                    (try_end),
                    (try_begin),
                        (neg|gt, ":var_34", 1),
                        (assign, ":var_40", 3),
                    (else_try),
                        (eq, ":var_34", 2),
                        (assign, ":var_40", 2),
                    (else_try),
                        (neg|gt, ":var_34", 6),
                        (assign, ":var_40", 1),
                    (else_try),
                        (assign, ":var_40", 0),
                    (try_end),
                    (store_mul, ":var_41", ":var_36", ":var_32"),
                    (val_mul, ":var_41", ":var_39"),
                    (val_div, ":var_41", 2),
                    (try_begin),
                        (gt, ":var_34", 0),
                        (store_div, ":var_42", ":var_41", ":var_34"),
                    (try_end),
                    (get_max_players, ":var_8"),
                    (try_for_range, ":var_9", 0, ":var_8"),
                        (player_is_active, ":var_9"),
                        (player_get_agent_id, ":var_10", ":var_9"),
                        (ge, ":var_10", 0),
                        (agent_get_team, ":var_11", ":var_10"),
                        (val_add, ":var_11", 1),
                        (eq, ":var_11", ":var_24"),
                        (agent_get_position, pos1, ":var_10"),
                        (prop_instance_get_position, pos0, ":var_7"),
                        (get_sq_distance_between_positions, ":var_12", pos0, pos1),
                        (get_sq_distance_between_position_heights, ":var_13", pos0, pos1),
                        (val_add, ":var_12", ":var_13"),
                        (neg|ge, ":var_12", 1600),
                        (player_get_score, ":var_43", ":var_9"),
                        (val_add, ":var_43", ":var_40"),
                        (player_set_score, ":var_9", ":var_43"),
                        (player_get_gold, ":var_44", ":var_9"),
                        (val_add, ":var_44", ":var_42"),
                        (player_set_gold, ":var_9", ":var_44", 15000),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (assign, ":var_3", 0),
        (try_for_range, ":var_4", 0, "$g_number_of_flags"),
            (store_add, ":var_5", 146, ":var_4"),
            (troop_get_slot, ":var_6", "trp_multiplayer_data", ":var_5"),
            (scene_prop_get_instance, ":var_7", "$team_1_flag_scene_prop", ":var_4"),
            (scene_prop_get_instance, ":var_8", "$team_2_flag_scene_prop", ":var_4"),
            (try_begin),
                (this_or_next|eq, "$g_base_flag_team_1", ":var_7"),
                (eq, "$g_base_flag_team_2", ":var_8"),
                (assign, ":var_9", 2),
            (else_try),
                (assign, ":var_9", 1),
            (try_end),
            (try_begin),
                (eq, ":var_6", 1),
                (val_add, ":var_0", ":var_9"),
                (val_add, ":var_2", ":var_9"),
            (else_try),
                (eq, ":var_6", 2),
                (val_add, ":var_1", ":var_9"),
                (val_add, ":var_2", ":var_9"),
            (else_try),
                (val_add, ":var_3", ":var_9"),
            (try_end),
        (try_end),
        (store_add, ":var_10", ":var_2", ":var_3"),
        (store_sub, ":var_11", ":var_0", ":var_1"),
        (store_mul, ":var_12", ":var_11", 2),
        (store_sub, ":var_13", "$g_number_of_initial_team_1_flags", "$g_number_of_initial_team_2_flags"),
        (assign, ":var_14", 0),
        (get_max_players, ":var_15"),
        (try_for_range, ":var_16", 0, ":var_15"),
            (player_is_active, ":var_16"),
            (val_add, ":var_14", 1),
            (assign, ":var_15", 0),
        (try_end),
        (try_begin),
            (ge, ":var_12", ":var_13"),
            (store_sub, ":var_17", ":var_12", ":var_13"),
            (store_mul, ":var_18", ":var_17", 125),
            (val_add, ":var_18", 500),
            (store_div, ":var_19", 250000, ":var_18"),
            (try_begin),
                (neg|ge, ":var_2", ":var_10"),
                (val_mul, ":var_19", ":var_2"),
                (val_div, ":var_19", ":var_10"),
                (val_mul, ":var_18", ":var_2"),
                (val_div, ":var_18", ":var_10"),
            (try_end),
            (call_script, "script_find_number_of_agents_constant"),
            (val_mul, ":var_18", reg0),
            (val_div, ":var_18", 100),
            (val_mul, ":var_19", reg0),
            (val_div, ":var_19", 100),
            (val_mul, ":var_18", "$g_multiplayer_point_gained_from_flags"),
            (val_div, ":var_18", 100),
            (val_mul, ":var_19", "$g_multiplayer_point_gained_from_flags"),
            (val_div, ":var_19", 100),
            (try_begin),
                (ge, ":var_14", 1),
                (val_sub, "$g_score_team_2", ":var_18"),
                (try_begin),
                    (ge, ":var_1", 1),
                    (val_sub, "$g_score_team_1", ":var_19"),
                (else_try),
                    (val_sub, "$g_score_team_2", ":var_19"),
                (try_end),
            (try_end),
        (else_try),
            (store_sub, ":var_17", ":var_13", ":var_12"),
            (store_mul, ":var_18", ":var_17", 125),
            (val_add, ":var_18", 500),
            (store_div, ":var_19", 250000, ":var_18"),
            (try_begin),
                (neg|ge, ":var_2", ":var_10"),
                (val_mul, ":var_19", ":var_2"),
                (val_div, ":var_19", ":var_10"),
                (val_mul, ":var_18", ":var_2"),
                (val_div, ":var_18", ":var_10"),
            (try_end),
            (call_script, "script_find_number_of_agents_constant"),
            (val_mul, ":var_18", reg0),
            (val_div, ":var_18", 100),
            (val_mul, ":var_19", reg0),
            (val_div, ":var_19", 100),
            (val_mul, ":var_18", "$g_multiplayer_point_gained_from_flags"),
            (val_div, ":var_18", 100),
            (val_mul, ":var_19", "$g_multiplayer_point_gained_from_flags"),
            (val_div, ":var_19", 100),
            (try_begin),
                (ge, ":var_14", 1),
                (try_begin),
                    (ge, ":var_0", 1),
                    (val_sub, "$g_score_team_2", ":var_19"),
                (else_try),
                    (val_sub, "$g_score_team_1", ":var_19"),
                (try_end),
                (val_sub, "$g_score_team_1", ":var_18"),
            (try_end),
        (try_end),
        (team_get_score, ":var_20", 0),
        (try_begin),
            (store_div, ":var_21", "$g_score_team_1", 10000),
            (neg|eq, ":var_21", ":var_20"),
            (get_max_players, ":var_22"),
            (call_script, "script_team_set_score", 0, ":var_21"),
            (try_for_range, ":var_16", 1, ":var_22"),
                (player_is_active, ":var_16"),
                (multiplayer_send_2_int_to_player, ":var_16", 72, 0, ":var_21"),
            (try_end),
        (try_end),
        (team_get_score, ":var_23", 1),
        (try_begin),
            (store_div, ":var_24", "$g_score_team_2", 10000),
            (neg|eq, ":var_24", ":var_23"),
            (get_max_players, ":var_22"),
            (call_script, "script_team_set_score", 1, ":var_24"),
            (try_for_range, ":var_16", 1, ":var_22"),
                (player_is_active, ":var_16"),
                (multiplayer_send_2_int_to_player, ":var_16", 72, 1, ":var_24"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (player_get_team_no, ":var_2", ":var_1"),
            (neg|ge, ":var_2", 2),
            (player_get_troop_id, ":var_3", ":var_1"),
            (ge, ":var_3", 0),
            (player_get_agent_id, ":var_4", ":var_1"),
            (assign, ":var_5", 0),
            (try_begin),
                (player_get_slot, ":var_6", ":var_1", 24),
                (eq, ":var_6", 1),
                (assign, ":var_5", 1),
                (player_set_slot, ":var_1", 24, 0),
            (else_try),
                (try_begin),
                    (neg|ge, ":var_4", 0),
                    (assign, ":var_5", 1),
                (else_try),
                    (neg|agent_is_alive, ":var_4"),
                    (agent_get_time_elapsed_since_removed, ":var_7", ":var_4"),
                    (gt, ":var_7", "$g_multiplayer_respawn_period"),
                    (assign, ":var_5", 1),
                (try_end),
            (try_end),
            (eq, ":var_5", 1),
            (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
            (troop_get_inventory_slot, ":var_8", ":var_3", 8),
            (try_begin),
                (ge, ":var_8", 0),
                (assign, ":var_9", 1),
            (else_try),
                (assign, ":var_9", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_9"),
            (player_spawn_new_agent, ":var_1", reg0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (try_for_agents, ":var_3"),
            (agent_is_non_player, ":var_3"),
            (agent_is_human, ":var_3"),
            (assign, ":var_4", 0),
            (try_begin),
                (agent_is_alive, ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (agent_get_time_elapsed_since_removed, ":var_5", ":var_3"),
                (neg|gt, ":var_5", "$g_multiplayer_respawn_period"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (agent_get_team, ":var_6", ":var_3"),
            (try_begin),
                (eq, ":var_6", 0),
                (val_add, ":var_1", 1),
            (else_try),
                (eq, ":var_6", 1),
                (val_add, ":var_2", 1),
            (try_end),
        (try_end),
        (store_sub, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1", ":var_1"),
        (store_sub, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2", ":var_2"),
        (val_max, "$g_multiplayer_num_bots_required_team_1", 0),
        (val_max, "$g_multiplayer_num_bots_required_team_2", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (this_or_next|eq, "$g_multiplayer_game_type", 3),
                (eq, "$g_multiplayer_game_type", 6),
                (team_get_score, ":var_1", 0),
                (team_get_score, ":var_2", 1),
                (store_add, ":var_3", ":var_1", ":var_2"),
                (eq, ":var_3", 0),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (neg|ge, ":var_4", 20),
                (assign, ":var_5", 0),
            (else_try),
                (assign, ":var_5", 1),
            (try_end),
            (eq, ":var_5", 1),
            (store_random_in_range, ":var_6", 0, ":var_0"),
            (val_sub, ":var_6", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_6", 0),
                (assign, ":var_7", 0),
            (else_try),
                (assign, ":var_7", 1),
            (try_end),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (eq, "$g_multiplayer_game_type", 3),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (try_begin),
                    (neg|gt, ":var_4", 20),
                    (assign, ":var_8", 0),
                (else_try),
                    (assign, ":var_8", 1),
                (try_end),
            (else_try),
                (assign, ":var_8", 1),
            (try_end),
            (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":var_7", ":var_8"),
            (assign, ":var_9", reg0),
            (assign, ":var_10", reg1),
            (team_get_faction, ":var_11", ":var_7"),
            (assign, ":var_12", 0),
            (try_for_range, ":var_13", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_14", ":var_13"),
                (eq, ":var_14", ":var_11"),
                (val_add, ":var_12", 1),
            (try_end),
            (assign, ":var_15", 0),
            (get_max_players, ":var_16"),
            (try_for_range, ":var_17", 0, ":var_16"),
                (player_is_active, ":var_17"),
                (player_get_team_no, ":var_18", ":var_17"),
                (eq, ":var_7", ":var_18"),
                (assign, ":var_19", 0),
                (store_add, ":var_20", 35, ":var_12"),
                (try_for_range, ":var_21", 35, ":var_20"),
                    (player_slot_ge, ":var_17", ":var_21", 1),
                    (assign, ":var_19", 1),
                    (assign, ":var_20", 0),
                (try_end),
                (ge, ":var_19", 1),
                (val_add, ":var_15", 1),
            (try_end),
            (try_begin),
                (this_or_next|ge, ":var_10", 0),
                (eq, ":var_15", 0),
                (troop_get_inventory_slot, ":var_22", ":var_9", 8),
                (try_begin),
                    (ge, ":var_22", 0),
                    (assign, ":var_23", 1),
                (else_try),
                    (assign, ":var_23", 0),
                (try_end),
                (try_begin),
                    (eq, "$g_multiplayer_game_type", 6),
                    (store_mission_timer_a, ":var_4"),
                    (val_sub, ":var_4", "$g_round_start_time"),
                    (try_begin),
                        (neg|ge, ":var_4", 20),
                        (try_begin),
                            (eq, ":var_7", 0),
                            (call_script, "script_multiplayer_find_spawn_point", ":var_7", 1, ":var_23"),
                        (else_try),
                            (assign, reg0, 32),
                        (try_end),
                    (else_try),
                        (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                    (try_end),
                (else_try),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, reg0, 0),
                    (else_try),
                        (assign, reg0, 32),
                    (try_end),
                (else_try),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                (try_end),
                (store_current_scene, ":var_24"),
                (modify_visitors_at_site, ":var_24"),
                (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_7", ":var_10"),
                (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
                (try_begin),
                    (eq, ":var_7", 0),
                    (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
                (else_try),
                    (eq, ":var_7", 1),
                    (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_agents, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_group, ":var_1", ":var_0"),
            (try_begin),
                (neg|player_is_active, ":var_1"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (else_try),
                (player_get_team_no, ":var_2", ":var_1"),
                (agent_get_team, ":var_3", ":var_0"),
                (neg|eq, ":var_2", ":var_3"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (try_end),
        (try_end),
    ]),

    (20.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (call_script, "script_check_team_balance"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_game_type", 2),
            (this_or_next|eq, "$g_multiplayer_game_type", 3),
            (eq, "$g_multiplayer_game_type", 6),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (store_mission_timer_a, ":var_1"),
                (val_sub, ":var_1", "$g_round_finish_time"),
                (store_sub, ":var_2", "$g_multiplayer_respawn_period", 1),
                (ge, ":var_1", ":var_2"),
                (store_mission_timer_a, ":var_3"),
                (try_begin),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (assign, ":var_4", 90),
                (else_try),
                    (assign, ":var_4", 120),
                (try_end),
                (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (gt, ":var_3", ":var_6"),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 1),
        (else_try),
            (neg|eq, "$g_multiplayer_game_type", 2),
            (neg|eq, "$g_multiplayer_game_type", 3),
            (neg|eq, "$g_multiplayer_game_type", 6),
            (neg|eq, "$g_multiplayer_game_type", 5),
            (store_mission_timer_a, ":var_3"),
            (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_3", ":var_5"),
            (assign, ":var_0", 1),
        (else_try),
            (team_get_score, ":var_7", 0),
            (team_get_score, ":var_8", 1),
            (try_begin),
                (neg|eq, "$g_multiplayer_game_type", 5),
                (try_begin),
                    (this_or_next|ge, ":var_7", "$g_multiplayer_game_max_points"),
                    (ge, ":var_8", "$g_multiplayer_game_max_points"),
                    (assign, ":var_0", 1),
                (try_end),
            (else_try),
                (assign, ":var_9", 0),
                (get_max_players, ":var_10"),
                (try_for_range, ":var_11", 0, ":var_10"),
                    (player_is_active, ":var_11"),
                    (player_get_agent_id, ":var_12", ":var_11"),
                    (ge, ":var_12", 0),
                    (neg|agent_is_non_player, ":var_12"),
                    (assign, ":var_9", 1),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_9", 1),
                (this_or_next|neg|gt, ":var_7", 0),
                (neg|gt, ":var_8", 0),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_team_score_display"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"multiplayer_cf", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(64, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(65, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (multiplayer_is_server),
            (store_current_scene, ":var_0"),
            (this_or_next|eq, ":var_0", "scn_random_multi_plain_medium"),
            (this_or_next|eq, ":var_0", "scn_random_multi_plain_large"),
            (this_or_next|eq, ":var_0", "scn_random_multi_steppe_medium"),
            (eq, ":var_0", "scn_random_multi_steppe_large"),
            (entry_point_get_position, pos0, 0),
            (entry_point_set_position, 64, pos0),
            (entry_point_get_position, pos1, 32),
            (entry_point_set_position, 65, pos1),
        (try_end),
        (assign, "$g_multiplayer_game_type", 4),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (assign, "$flag_1_at_ground_timer", 0),
        (assign, "$flag_2_at_ground_timer", 0),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_determine_team_flags", 0),
        (call_script, "script_determine_team_flags", 1),
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
            (entry_point_get_position, pos0, 64),
            (set_spawn_position, pos0),
            (spawn_scene_prop, "$team_1_flag_scene_prop", 0),
            (entry_point_get_position, pos0, 65),
            (set_spawn_position, pos0),
            (spawn_scene_prop, "$team_2_flag_scene_prop", 0),
        (try_end),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (agent_is_human, ":var_0"),
            (agent_get_attached_scene_prop, ":var_2", ":var_0"),
            (try_begin),
                (try_begin),
                    (multiplayer_is_server),
                    (ge, ":var_2", 0),
                    (multiplayer_get_my_player, ":var_3"),
                    (get_max_players, ":var_4"),
                    (call_script, "script_set_attached_scene_prop", ":var_0", -1),
                    (agent_set_horse_speed_factor, ":var_0", 100),
                    (try_for_range, ":var_5", 1, ":var_4"),
                        (player_is_active, ":var_5"),
                        (neg|eq, ":var_3", ":var_5"),
                        (multiplayer_send_2_int_to_player, ":var_5", 70, ":var_0", -1),
                    (try_end),
                    (prop_instance_get_position, pos0, ":var_2"),
                    (position_set_z_to_ground_level, pos0),
                    (prop_instance_set_position, ":var_2", pos0),
                    (agent_get_team, ":var_6", ":var_0"),
                    (try_begin),
                        (eq, ":var_6", 0),
                        (assign, ":var_7", 1),
                    (else_try),
                        (assign, ":var_7", 0),
                    (try_end),
                    (team_set_slot, ":var_7", 0, 2),
                    (multiplayer_get_my_player, ":var_3"),
                    (get_max_players, ":var_4"),
                    (call_script, "script_set_team_flag_situation", ":var_7", 2),
                    (try_for_range, ":var_5", 1, ":var_4"),
                        (player_is_active, ":var_5"),
                        (neg|eq, ":var_3", ":var_5"),
                        (multiplayer_send_2_int_to_player, ":var_5", 71, ":var_7", 2),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_range, ":var_0", 0, 2),
            (try_begin),
                (team_slot_eq, ":var_0", 0, 2),
                (assign, ":var_1", -1),
                (try_begin),
                    (eq, ":var_0", 0),
                    (val_add, "$flag_1_at_ground_timer", 1),
                    (ge, "$flag_1_at_ground_timer", 60),
                    (assign, ":var_1", 0),
                (else_try),
                    (val_add, "$flag_2_at_ground_timer", 1),
                    (ge, "$flag_2_at_ground_timer", 60),
                    (assign, ":var_1", 1),
                (try_end),
                (try_begin),
                    (ge, ":var_1", 0),
                    (try_begin),
                        (eq, ":var_1", 0),
                        (assign, "$flag_1_at_ground_timer", 0),
                    (else_try),
                        (eq, ":var_1", 1),
                        (assign, "$flag_2_at_ground_timer", 0),
                    (try_end),
                    (team_set_slot, ":var_1", 0, 0),
                    (call_script, "script_set_team_flag_situation", ":var_1", 0),
                    (multiplayer_get_my_player, ":var_2"),
                    (get_max_players, ":var_3"),
                    (try_for_range, ":var_4", 1, ":var_3"),
                        (player_is_active, ":var_4"),
                        (neg|eq, ":var_2", ":var_4"),
                        (multiplayer_send_2_int_to_player, ":var_4", 71, ":var_1", 0),
                    (try_end),
                    (scene_prop_get_instance, ":var_5", "$team_1_flag_scene_prop", 0),
                    (scene_prop_get_instance, ":var_6", "$team_2_flag_scene_prop", 0),
                    (assign, ":var_7", ":var_5"),
                    (assign, ":var_8", 64),
                    (assign, ":var_9", ":var_6"),
                    (assign, ":var_10", 65),
                    (try_begin),
                        (eq, ":var_1", 0),
                        (entry_point_get_position, pos5, ":var_8"),
                        (prop_instance_set_position, ":var_7", pos5),
                    (else_try),
                        (entry_point_get_position, pos5, ":var_10"),
                        (prop_instance_set_position, ":var_9", pos5),
                    (try_end),
                    (store_mul, ":var_11", ":var_1", -1),
                    (val_sub, ":var_11", 1),
                    (call_script, "script_show_multiplayer_message", 5, ":var_11"),
                    (try_for_range, ":var_4", 0, ":var_3"),
                        (player_is_active, ":var_4"),
                        (neg|eq, ":var_2", ":var_4"),
                        (multiplayer_send_2_int_to_player, ":var_4", 68, 5, ":var_11"),
                    (try_end),
                (try_end),
            (else_try),
                (try_begin),
                    (eq, ":var_0", 0),
                    (assign, "$flag_1_at_ground_timer", 0),
                (else_try),
                    (assign, "$flag_2_at_ground_timer", 0),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (player_get_team_no, ":var_2", ":var_1"),
            (neg|ge, ":var_2", 2),
            (player_get_troop_id, ":var_3", ":var_1"),
            (ge, ":var_3", 0),
            (player_get_agent_id, ":var_4", ":var_1"),
            (assign, ":var_5", 0),
            (try_begin),
                (player_get_slot, ":var_6", ":var_1", 24),
                (eq, ":var_6", 1),
                (assign, ":var_5", 1),
                (player_set_slot, ":var_1", 24, 0),
            (else_try),
                (try_begin),
                    (neg|ge, ":var_4", 0),
                    (assign, ":var_5", 1),
                (else_try),
                    (neg|agent_is_alive, ":var_4"),
                    (agent_get_time_elapsed_since_removed, ":var_7", ":var_4"),
                    (gt, ":var_7", "$g_multiplayer_respawn_period"),
                    (assign, ":var_5", 1),
                (try_end),
            (try_end),
            (eq, ":var_5", 1),
            (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
            (troop_get_inventory_slot, ":var_8", ":var_3", 8),
            (try_begin),
                (ge, ":var_8", 0),
                (assign, ":var_9", 1),
            (else_try),
                (assign, ":var_9", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_9"),
            (player_spawn_new_agent, ":var_1", reg0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (try_for_agents, ":var_3"),
            (agent_is_non_player, ":var_3"),
            (agent_is_human, ":var_3"),
            (assign, ":var_4", 0),
            (try_begin),
                (agent_is_alive, ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (agent_get_time_elapsed_since_removed, ":var_5", ":var_3"),
                (neg|gt, ":var_5", "$g_multiplayer_respawn_period"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (agent_get_team, ":var_6", ":var_3"),
            (try_begin),
                (eq, ":var_6", 0),
                (val_add, ":var_1", 1),
            (else_try),
                (eq, ":var_6", 1),
                (val_add, ":var_2", 1),
            (try_end),
        (try_end),
        (store_sub, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1", ":var_1"),
        (store_sub, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2", ":var_2"),
        (val_max, "$g_multiplayer_num_bots_required_team_1", 0),
        (val_max, "$g_multiplayer_num_bots_required_team_2", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (this_or_next|eq, "$g_multiplayer_game_type", 3),
                (eq, "$g_multiplayer_game_type", 6),
                (team_get_score, ":var_1", 0),
                (team_get_score, ":var_2", 1),
                (store_add, ":var_3", ":var_1", ":var_2"),
                (eq, ":var_3", 0),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (neg|ge, ":var_4", 20),
                (assign, ":var_5", 0),
            (else_try),
                (assign, ":var_5", 1),
            (try_end),
            (eq, ":var_5", 1),
            (store_random_in_range, ":var_6", 0, ":var_0"),
            (val_sub, ":var_6", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_6", 0),
                (assign, ":var_7", 0),
            (else_try),
                (assign, ":var_7", 1),
            (try_end),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (eq, "$g_multiplayer_game_type", 3),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (try_begin),
                    (neg|gt, ":var_4", 20),
                    (assign, ":var_8", 0),
                (else_try),
                    (assign, ":var_8", 1),
                (try_end),
            (else_try),
                (assign, ":var_8", 1),
            (try_end),
            (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":var_7", ":var_8"),
            (assign, ":var_9", reg0),
            (assign, ":var_10", reg1),
            (team_get_faction, ":var_11", ":var_7"),
            (assign, ":var_12", 0),
            (try_for_range, ":var_13", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_14", ":var_13"),
                (eq, ":var_14", ":var_11"),
                (val_add, ":var_12", 1),
            (try_end),
            (assign, ":var_15", 0),
            (get_max_players, ":var_16"),
            (try_for_range, ":var_17", 0, ":var_16"),
                (player_is_active, ":var_17"),
                (player_get_team_no, ":var_18", ":var_17"),
                (eq, ":var_7", ":var_18"),
                (assign, ":var_19", 0),
                (store_add, ":var_20", 35, ":var_12"),
                (try_for_range, ":var_21", 35, ":var_20"),
                    (player_slot_ge, ":var_17", ":var_21", 1),
                    (assign, ":var_19", 1),
                    (assign, ":var_20", 0),
                (try_end),
                (ge, ":var_19", 1),
                (val_add, ":var_15", 1),
            (try_end),
            (try_begin),
                (this_or_next|ge, ":var_10", 0),
                (eq, ":var_15", 0),
                (troop_get_inventory_slot, ":var_22", ":var_9", 8),
                (try_begin),
                    (ge, ":var_22", 0),
                    (assign, ":var_23", 1),
                (else_try),
                    (assign, ":var_23", 0),
                (try_end),
                (try_begin),
                    (eq, "$g_multiplayer_game_type", 6),
                    (store_mission_timer_a, ":var_4"),
                    (val_sub, ":var_4", "$g_round_start_time"),
                    (try_begin),
                        (neg|ge, ":var_4", 20),
                        (try_begin),
                            (eq, ":var_7", 0),
                            (call_script, "script_multiplayer_find_spawn_point", ":var_7", 1, ":var_23"),
                        (else_try),
                            (assign, reg0, 32),
                        (try_end),
                    (else_try),
                        (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                    (try_end),
                (else_try),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, reg0, 0),
                    (else_try),
                        (assign, reg0, 32),
                    (try_end),
                (else_try),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                (try_end),
                (store_current_scene, ":var_24"),
                (modify_visitors_at_site, ":var_24"),
                (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_7", ":var_10"),
                (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
                (try_begin),
                    (eq, ":var_7", 0),
                    (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
                (else_try),
                    (eq, ":var_7", 1),
                    (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_agents, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_group, ":var_1", ":var_0"),
            (try_begin),
                (neg|player_is_active, ":var_1"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (else_try),
                (player_get_team_no, ":var_2", ":var_1"),
                (agent_get_team, ":var_3", ":var_0"),
                (neg|eq, ":var_2", ":var_3"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (scene_prop_get_instance, ":var_0", "$team_1_flag_scene_prop", 0),
        (prop_instance_get_position, pos1, ":var_0"),
        (scene_prop_get_instance, ":var_1", "$team_2_flag_scene_prop", 0),
        (prop_instance_get_position, pos2, ":var_1"),
        (multiplayer_get_my_player, ":var_2"),
        (get_max_players, ":var_3"),
        (try_for_agents, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_is_alive, ":var_4"),
            (neg|agent_is_non_player, ":var_4"),
            (agent_get_horse, ":var_5", ":var_4"),
            (eq, ":var_5", -1),
            (agent_get_attached_scene_prop, ":var_6", ":var_4"),
            (agent_get_team, ":var_7", ":var_4"),
            (try_begin),
                (eq, ":var_7", 0),
                (assign, ":var_8", 1),
            (else_try),
                (assign, ":var_8", 0),
            (try_end),
            (try_begin),
                (eq, ":var_7", 0),
                (assign, ":var_9", ":var_0"),
                (assign, ":var_10", 64),
            (else_try),
                (assign, ":var_9", ":var_1"),
                (assign, ":var_10", 65),
            (try_end),
            (agent_get_position, pos3, ":var_4"),
            (prop_instance_get_position, pos4, ":var_9"),
            (get_distance_between_positions, ":var_11", pos3, pos4),
            (team_get_slot, ":var_12", ":var_7", 0),
            (try_begin),
                (eq, ":var_12", 2),
                (neg|ge, ":var_11", 100),
                (team_set_slot, ":var_7", 0, 0),
                (call_script, "script_set_team_flag_situation", ":var_7", 0),
                (try_for_range, ":var_13", 1, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 71, ":var_7", 0),
                (try_end),
                (entry_point_get_position, pos5, ":var_10"),
                (prop_instance_set_position, ":var_9", pos5),
                (try_begin),
                    (multiplayer_is_server),
                    (neg|agent_is_non_player, ":var_4"),
                    (agent_get_player_id, ":var_14", ":var_4"),
                    (player_get_score, ":var_15", ":var_14"),
                    (val_add, ":var_15", 1),
                    (player_set_score, ":var_14", ":var_15"),
                (try_end),
                (call_script, "script_show_multiplayer_message", 5, ":var_4"),
                (try_for_range, ":var_13", 0, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 68, 5, ":var_4"),
                (try_end),
            (try_end),
            (try_begin),
                (neg|eq, ":var_6", -1),
                (try_begin),
                    (eq, ":var_7", 0),
                    (assign, ":var_16", ":var_1"),
                    (assign, ":var_17", 65),
                (else_try),
                    (assign, ":var_16", ":var_0"),
                    (assign, ":var_17", 64),
                (try_end),
                (eq, ":var_6", ":var_16"),
                (eq, ":var_12", 0),
                (neg|ge, ":var_11", 100),
                (team_get_score, ":var_18", ":var_7"),
                (val_add, ":var_18", 1),
                (team_set_score, ":var_7", ":var_18"),
                (try_begin),
                    (multiplayer_is_server),
                    (neg|agent_is_non_player, ":var_4"),
                    (agent_get_player_id, ":var_14", ":var_4"),
                    (player_get_score, ":var_15", ":var_14"),
                    (val_add, ":var_15", "$g_multiplayer_point_gained_from_capturing_flag"),
                    (player_set_score, ":var_14", ":var_15"),
                (try_end),
                (call_script, "script_team_set_score", ":var_7", ":var_18"),
                (try_for_range, ":var_13", 1, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 72, ":var_7", ":var_18"),
                (try_end),
                (agent_set_attached_scene_prop, ":var_4", -1),
                (team_set_slot, ":var_8", 0, 0),
                (call_script, "script_set_attached_scene_prop", ":var_4", -1),
                (agent_set_horse_speed_factor, ":var_4", 100),
                (try_for_range, ":var_13", 1, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 70, ":var_4", -1),
                (try_end),
                (call_script, "script_set_team_flag_situation", ":var_8", 0),
                (try_for_range, ":var_13", 1, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 71, ":var_8", 0),
                (try_end),
                (entry_point_get_position, pos5, ":var_17"),
                (prop_instance_set_position, ":var_16", pos5),
                (call_script, "script_show_multiplayer_message", 4, ":var_4"),
                (try_for_range, ":var_13", 0, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 68, 4, ":var_4"),
                (try_end),
            (try_end),
            (eq, ":var_6", -1),
            (agent_get_position, pos3, ":var_4"),
            (agent_get_team, ":var_7", ":var_4"),
            (try_begin),
                (eq, ":var_7", 0),
                (get_distance_between_positions, ":var_11", pos2, pos3),
                (assign, ":var_16", ":var_1"),
            (else_try),
                (get_distance_between_positions, ":var_11", pos1, pos3),
                (assign, ":var_16", ":var_0"),
            (try_end),
            (try_begin),
                (neg|gt, ":var_11", 100),
                (neg|team_slot_eq, ":var_8", 0, 1),
                (agent_set_attached_scene_prop, ":var_4", ":var_16"),
                (agent_set_attached_scene_prop_x, ":var_4", 20),
                (agent_set_attached_scene_prop_z, ":var_4", 50),
                (try_begin),
                    (eq, ":var_7", 0),
                    (assign, "$flag_1_at_ground_timer", 0),
                (else_try),
                    (eq, ":var_7", 1),
                    (assign, "$flag_2_at_ground_timer", 0),
                (try_end),
                (team_set_slot, ":var_8", 0, 1),
                (call_script, "script_set_attached_scene_prop", ":var_4", ":var_16"),
                (agent_set_horse_speed_factor, ":var_4", 75),
                (try_for_range, ":var_13", 1, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 70, ":var_4", ":var_16"),
                (try_end),
                (call_script, "script_set_team_flag_situation", ":var_8", 1),
                (try_for_range, ":var_13", 1, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 71, ":var_8", 1),
                (try_end),
                (call_script, "script_show_multiplayer_message", 6, ":var_4"),
                (try_for_range, ":var_13", 0, ":var_3"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_2", ":var_13"),
                    (multiplayer_send_2_int_to_player, ":var_13", 68, 6, ":var_4"),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (20.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (call_script, "script_check_team_balance"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_game_type", 2),
            (this_or_next|eq, "$g_multiplayer_game_type", 3),
            (eq, "$g_multiplayer_game_type", 6),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (store_mission_timer_a, ":var_1"),
                (val_sub, ":var_1", "$g_round_finish_time"),
                (store_sub, ":var_2", "$g_multiplayer_respawn_period", 1),
                (ge, ":var_1", ":var_2"),
                (store_mission_timer_a, ":var_3"),
                (try_begin),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (assign, ":var_4", 90),
                (else_try),
                    (assign, ":var_4", 120),
                (try_end),
                (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (gt, ":var_3", ":var_6"),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 1),
        (else_try),
            (neg|eq, "$g_multiplayer_game_type", 2),
            (neg|eq, "$g_multiplayer_game_type", 3),
            (neg|eq, "$g_multiplayer_game_type", 6),
            (neg|eq, "$g_multiplayer_game_type", 5),
            (store_mission_timer_a, ":var_3"),
            (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_3", ":var_5"),
            (assign, ":var_0", 1),
        (else_try),
            (team_get_score, ":var_7", 0),
            (team_get_score, ":var_8", 1),
            (try_begin),
                (neg|eq, "$g_multiplayer_game_type", 5),
                (try_begin),
                    (this_or_next|ge, ":var_7", "$g_multiplayer_game_max_points"),
                    (ge, ":var_8", "$g_multiplayer_game_max_points"),
                    (assign, ":var_0", 1),
                (try_end),
            (else_try),
                (assign, ":var_9", 0),
                (get_max_players, ":var_10"),
                (try_for_range, ":var_11", 0, ":var_10"),
                    (player_is_active, ":var_11"),
                    (player_get_agent_id, ":var_12", ":var_11"),
                    (ge, ":var_12", 0),
                    (neg|agent_is_non_player, ":var_12"),
                    (assign, ":var_9", 1),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_9", 1),
                (this_or_next|neg|gt, ":var_7", 0),
                (neg|gt, ":var_8", 0),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_team_score_display"),
        (start_presentation, "prsnt_multiplayer_flag_projection_display"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"multiplayer_sg", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(2, mtef_visitor_source, 0, 16, 1, []),
(3, mtef_visitor_source, 0, 16, 1, []),
(4, mtef_visitor_source, 0, 16, 1, []),
(5, mtef_visitor_source, 0, 16, 1, []),
(6, mtef_visitor_source, 0, 16, 1, []),
(7, mtef_visitor_source, 0, 16, 1, []),
(8, mtef_visitor_source, 0, 16, 1, []),
(9, mtef_visitor_source, 0, 16, 1, []),
(10, mtef_visitor_source, 0, 16, 1, []),
(11, mtef_visitor_source, 0, 16, 1, []),
(12, mtef_visitor_source, 0, 16, 1, []),
(13, mtef_visitor_source, 0, 16, 1, []),
(14, mtef_visitor_source, 0, 16, 1, []),
(15, mtef_visitor_source, 0, 16, 1, []),
(16, mtef_visitor_source, 0, 16, 1, []),
(17, mtef_visitor_source, 0, 16, 1, []),
(18, mtef_visitor_source, 0, 16, 1, []),
(19, mtef_visitor_source, 0, 16, 1, []),
(20, mtef_visitor_source, 0, 16, 1, []),
(21, mtef_visitor_source, 0, 16, 1, []),
(22, mtef_visitor_source, 0, 16, 1, []),
(23, mtef_visitor_source, 0, 16, 1, []),
(24, mtef_visitor_source, 0, 16, 1, []),
(25, mtef_visitor_source, 0, 16, 1, []),
(26, mtef_visitor_source, 0, 16, 1, []),
(27, mtef_visitor_source, 0, 16, 1, []),
(28, mtef_visitor_source, 0, 16, 1, []),
(29, mtef_visitor_source, 0, 16, 1, []),
(30, mtef_visitor_source, 0, 16, 1, []),
(31, mtef_visitor_source, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1|mtef_no_auto_reset, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1|mtef_no_auto_reset, 0, 16, 1, []),
(34, mtef_visitor_source, 0, 16, 1, []),
(35, mtef_visitor_source, 0, 16, 1, []),
(36, mtef_visitor_source, 0, 16, 1, []),
(37, mtef_visitor_source, 0, 16, 1, []),
(38, mtef_visitor_source, 0, 16, 1, []),
(39, mtef_visitor_source, 0, 16, 1, []),
(40, mtef_visitor_source, 0, 16, 1, []),
(41, mtef_visitor_source, 0, 16, 1, []),
(42, mtef_visitor_source, 0, 16, 1, []),
(43, mtef_visitor_source, 0, 16, 1, []),
(44, mtef_visitor_source, 0, 16, 1, []),
(45, mtef_visitor_source, 0, 16, 1, []),
(46, mtef_visitor_source, 0, 16, 1, []),
(47, mtef_visitor_source, 0, 16, 1, []),
(48, mtef_visitor_source, 0, 16, 1, []),
(49, mtef_visitor_source, 0, 16, 1, []),
(50, mtef_visitor_source, 0, 16, 1, []),
(51, mtef_visitor_source, 0, 16, 1, []),
(52, mtef_visitor_source, 0, 16, 1, []),
(53, mtef_visitor_source, 0, 16, 1, []),
(54, mtef_visitor_source, 0, 16, 1, []),
(55, mtef_visitor_source, 0, 16, 1, []),
(56, mtef_visitor_source, 0, 16, 1, []),
(57, mtef_visitor_source, 0, 16, 1, []),
(58, mtef_visitor_source, 0, 16, 1, []),
(59, mtef_visitor_source, 0, 16, 1, []),
(60, mtef_visitor_source, 0, 16, 1, []),
(61, mtef_visitor_source, 0, 16, 1, []),
(62, mtef_visitor_source, 0, 16, 1, []),
(63, mtef_visitor_source, 0, 16, 1, []),
],
[
    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (set_fixed_point_multiplier, 100),
        (try_for_range, ":var_0", 0, 2),
            (try_begin),
                (eq, ":var_0", 0),
                (assign, ":var_1", "spr_belfry_a"),
            (else_try),
                (assign, ":var_1", "spr_belfry_b"),
            (try_end),
            (scene_prop_get_num_instances, ":var_2", ":var_1"),
            (try_for_range, ":var_3", 0, ":var_2"),
                (scene_prop_get_instance, ":var_4", ":var_1", ":var_3"),
                (prop_instance_get_position, pos1, ":var_4"),
                (prop_instance_get_starting_position, pos11, ":var_4"),
                (store_add, ":var_5", 11, ":var_3"),
                (try_begin),
                    (eq, ":var_0", 1),
                    (scene_prop_get_num_instances, ":var_6", "spr_belfry_a"),
                    (val_add, ":var_5", ":var_6"),
                (try_end),
                (val_mul, ":var_5", 10),
                (store_add, ":var_7", ":var_5", 10),
                (try_for_range, ":var_8", ":var_5", ":var_7"),
                    (entry_point_is_auto_generated, ":var_8"),
                    (assign, ":var_7", ":var_8"),
                (try_end),
                (assign, ":var_9", ":var_7"),
                (val_sub, ":var_7", 1),
                (assign, reg0, ":var_7"),
                (neg|entry_point_is_auto_generated, ":var_7"),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_10", pos1, pos11),
                    (ge, ":var_10", 4),
                    (assign, ":var_11", -1),
                    (assign, ":var_12", -1),
                    (try_for_range, ":var_8", ":var_5", ":var_9"),
                        (entry_point_get_position, pos4, ":var_8"),
                        (get_sq_distance_between_positions, ":var_13", pos11, pos4),
                        (neg|ge, ":var_13", ":var_10"),
                        (gt, ":var_13", ":var_11"),
                        (assign, ":var_11", ":var_13"),
                        (assign, ":var_12", ":var_8"),
                    (try_end),
                    (try_begin),
                        (ge, ":var_12", 0),
                        (entry_point_get_position, pos5, ":var_12"),
                    (else_try),
                        (copy_position, pos5, pos11),
                    (try_end),
                    (get_distance_between_positions, ":var_14", pos1, pos5),
                    (try_begin),
                        (eq, ":var_0", 0),
                        (scene_prop_get_instance, ":var_15", "spr_belfry_platform_a", ":var_3"),
                        (scene_prop_get_instance, ":var_16", "spr_belfry_platform_b", ":var_3"),
                    (else_try),
                        (scene_prop_get_instance, ":var_15", "spr_belfry_b_platform_a", ":var_3"),
                    (try_end),
                    (store_mul, ":var_17", ":var_3", 3),
                    (try_begin),
                        (eq, ":var_1", "spr_belfry_b"),
                        (scene_prop_get_num_instances, ":var_6", "spr_belfry_a"),
                        (store_mul, ":var_18", ":var_6", 3),
                        (val_add, ":var_17", ":var_18"),
                    (try_end),
                    (scene_prop_get_instance, ":var_19", "spr_belfry_wheel", ":var_17"),
                    (val_add, ":var_17", 1),
                    (scene_prop_get_instance, ":var_20", "spr_belfry_wheel", ":var_17"),
                    (val_add, ":var_17", 1),
                    (scene_prop_get_instance, ":var_21", "spr_belfry_wheel", ":var_17"),
                    (init_position, pos17),
                    (position_move_y, pos17, -225),
                    (position_transform_position_to_parent, pos18, pos1, pos17),
                    (position_move_y, pos17, -225),
                    (position_transform_position_to_parent, pos19, pos1, pos17),
                    (assign, ":var_22", 0),
                    (get_max_players, ":var_23"),
                    (try_for_range, ":var_24", 0, ":var_23"),
                        (player_is_active, ":var_24"),
                        (player_get_agent_id, ":var_25", ":var_24"),
                        (ge, ":var_25", 0),
                        (agent_get_team, ":var_26", ":var_25"),
                        (eq, ":var_26", 1),
                        (agent_get_horse, ":var_27", ":var_25"),
                        (eq, ":var_27", -1),
                        (agent_get_position, pos2, ":var_25"),
                        (get_sq_distance_between_positions_in_meters, ":var_28", pos18, pos2),
                        (neg|ge, ":var_28", 36),
                        (neg|scene_prop_has_agent_on_it, ":var_4", ":var_25"),
                        (neg|scene_prop_has_agent_on_it, ":var_15", ":var_25"),
                        (this_or_next|eq, ":var_0", 1),
                        (neg|scene_prop_has_agent_on_it, ":var_16", ":var_25"),
                        (neg|scene_prop_has_agent_on_it, ":var_19", ":var_25"),
                        (neg|scene_prop_has_agent_on_it, ":var_20", ":var_25"),
                        (neg|scene_prop_has_agent_on_it, ":var_21", ":var_25"),
                        (neg|position_is_behind_position, 2, 19),
                        (position_is_behind_position, pos2, pos1),
                        (val_add, ":var_22", 1),
                    (try_end),
                    (val_min, ":var_22", 16),
                    (try_begin),
                        (scene_prop_get_slot, ":var_29", ":var_4", 3),
                        (scene_prop_get_slot, ":var_30", ":var_4", 4),
                        (this_or_next|neg|eq, ":var_29", ":var_22"),
                        (neg|eq, ":var_30", ":var_12"),
                        (try_begin),
                            (eq, ":var_30", ":var_12"),
                            (prop_instance_is_animating, ":var_31", ":var_4"),
                            (eq, ":var_31", 1),
                            (store_mul, ":var_32", "$g_last_number_of_agents_around_belfry", 100),
                            (store_sqrt, ":var_32", ":var_32"),
                            (val_min, ":var_32", 300),
                            (assign, ":var_33", ":var_14"),
                            (val_mul, ":var_33", ":var_32"),
                            (val_div, ":var_33", 100),
                            (val_mul, ":var_33", 4),
                        (try_end),
                        (try_begin),
                            (ge, ":var_12", 0),
                            (init_position, pos9),
                            (position_set_y, pos9, -500),
                            (position_set_x, pos9, -300),
                            (position_transform_position_to_parent, pos10, pos5, pos9),
                            (position_get_distance_to_terrain, ":var_34", pos10),
                            (init_position, pos9),
                            (position_set_y, pos9, -500),
                            (position_set_x, pos9, 300),
                            (position_transform_position_to_parent, pos10, pos5, pos9),
                            (position_get_distance_to_terrain, ":var_35", pos10),
                            (store_add, ":var_36", ":var_34", ":var_35"),
                            (val_mul, ":var_36", 100),
                            (store_div, ":var_37", ":var_36", 24),
                            (init_position, pos20),
                            (position_rotate_x_floating, pos20, ":var_37"),
                            (position_transform_position_to_parent, pos23, pos5, pos20),
                            (init_position, pos9),
                            (position_set_x, pos9, -300),
                            (position_transform_position_to_parent, pos10, pos5, pos9),
                            (position_get_distance_to_terrain, ":var_38", pos10),
                            (init_position, pos9),
                            (position_set_x, pos9, 300),
                            (position_transform_position_to_parent, pos10, pos5, pos9),
                            (position_get_distance_to_terrain, ":var_39", pos10),
                            (store_sub, ":var_34", ":var_38", ":var_39"),
                            (init_position, pos9),
                            (position_set_x, pos9, -300),
                            (position_set_y, pos9, -500),
                            (position_transform_position_to_parent, pos10, pos5, pos9),
                            (position_get_distance_to_terrain, ":var_38", pos10),
                            (init_position, pos9),
                            (position_set_x, pos9, 300),
                            (position_set_y, pos9, -500),
                            (position_transform_position_to_parent, pos10, pos5, pos9),
                            (position_get_distance_to_terrain, ":var_39", pos10),
                            (store_sub, ":var_35", ":var_38", ":var_39"),
                            (store_add, ":var_36", ":var_34", ":var_35"),
                            (val_mul, ":var_36", 100),
                            (store_div, ":var_37", ":var_36", 24),
                            (val_mul, ":var_37", -1),
                            (init_position, pos20),
                            (position_rotate_y_floating, pos20, ":var_37"),
                            (position_transform_position_to_parent, pos22, pos23, pos20),
                        (else_try),
                            (copy_position, pos22, pos5),
                        (try_end),
                        (try_begin),
                            (ge, ":var_22", 1),
                            (store_mul, ":var_32", ":var_22", 100),
                            (store_sqrt, ":var_32", ":var_32"),
                            (val_min, ":var_32", 300),
                            (val_mul, ":var_14", 100),
                            (val_mul, ":var_14", 3),
                            (val_div, ":var_14", ":var_32"),
                            (prop_instance_get_position, pos6, ":var_15"),
                            (position_transform_position_to_local, pos7, pos1, pos6),
                            (position_transform_position_to_parent, pos8, pos22, pos7),
                            (prop_instance_animate_to_position, ":var_15", 8, ":var_14"),
                            (try_begin),
                                (eq, ":var_0", 0),
                                (prop_instance_get_position, pos6, ":var_16"),
                                (position_transform_position_to_local, pos7, pos1, pos6),
                                (position_transform_position_to_parent, pos8, pos22, pos7),
                                (prop_instance_animate_to_position, ":var_16", 8, ":var_14"),
                            (try_end),
                            (store_mul, ":var_40", ":var_14", -25),
                            (assign, "$g_last_number_of_agents_around_belfry", ":var_22"),
                            (prop_instance_get_position, pos13, ":var_19"),
                            (prop_instance_get_position, pos20, ":var_4"),
                            (position_transform_position_to_local, pos7, pos20, pos13),
                            (position_transform_position_to_parent, pos21, pos22, pos7),
                            (prop_instance_rotate_to_position, ":var_19", 21, ":var_14", ":var_40"),
                            (prop_instance_get_position, pos13, ":var_20"),
                            (prop_instance_get_position, pos20, ":var_4"),
                            (position_transform_position_to_local, pos7, pos20, pos13),
                            (position_transform_position_to_parent, pos21, pos22, pos7),
                            (prop_instance_rotate_to_position, ":var_20", 21, ":var_14", ":var_40"),
                            (prop_instance_get_position, pos13, ":var_21"),
                            (prop_instance_get_position, pos20, ":var_4"),
                            (position_transform_position_to_local, pos7, pos20, pos13),
                            (position_transform_position_to_parent, pos21, pos22, pos7),
                            (prop_instance_rotate_to_position, ":var_21", 21, ":var_14", ":var_40"),
                            (prop_instance_animate_to_position, ":var_4", 22, ":var_14"),
                        (else_try),
                            (prop_instance_is_animating, ":var_31", ":var_4"),
                            (eq, ":var_31", 1),
                            (prop_instance_stop_animating, ":var_15"),
                            (try_begin),
                                (eq, ":var_0", 0),
                                (prop_instance_stop_animating, ":var_16"),
                            (try_end),
                            (prop_instance_stop_animating, ":var_19"),
                            (prop_instance_stop_animating, ":var_20"),
                            (prop_instance_stop_animating, ":var_21"),
                            (prop_instance_stop_animating, ":var_4"),
                        (try_end),
                        (scene_prop_set_slot, ":var_4", 3, ":var_22"),
                        (scene_prop_set_slot, ":var_4", 4, ":var_12"),
                    (try_end),
                (else_try),
                    (neg|gt, ":var_10", 4),
                    (scene_prop_slot_eq, ":var_4", 5, 0),
                    (scene_prop_set_slot, ":var_4", 5, 1),
                    (try_begin),
                        (eq, ":var_0", 0),
                        (scene_prop_get_instance, ":var_15", "spr_belfry_platform_a", ":var_3"),
                    (else_try),
                        (scene_prop_get_instance, ":var_15", "spr_belfry_b_platform_a", ":var_3"),
                    (try_end),
                    (prop_instance_get_starting_position, pos0, ":var_15"),
                    (prop_instance_animate_to_position, ":var_15", 0, 400),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
        (try_begin),
            (multiplayer_is_server),
            (this_or_next|player_is_active, ":var_0"),
            (eq, ":var_0", 0),
            (store_mission_timer_a, ":var_1"),
            (val_sub, ":var_1", "$g_round_start_time"),
            (try_begin),
                (neg|ge, ":var_1", 25),
                (assign, ":var_2", 0),
            (else_try),
                (neg|ge, ":var_1", 60),
                (assign, ":var_2", 1),
            (else_try),
                (neg|ge, ":var_1", 105),
                (assign, ":var_2", 2),
            (else_try),
                (neg|ge, ":var_1", 160),
                (assign, ":var_2", 3),
            (else_try),
                (assign, ":var_2", "$g_multiplayer_number_of_respawn_count"),
            (try_end),
            (player_set_slot, ":var_0", 39, ":var_2"),
            (multiplayer_send_int_to_player, ":var_0", 89, ":var_2"),
        (try_end),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 6),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (try_begin),
            (multiplayer_is_server),
            (try_for_range, ":var_0", 176, 186),
                (troop_set_slot, "trp_multiplayer_data", ":var_0", -1),
            (try_end),
            (assign, "$g_my_spawn_count", 0),
        (else_try),
            (assign, "$g_my_spawn_count", 0),
        (try_end),
        (assign, "$g_waiting_for_confirmation_to_terminate", 0),
        (assign, "$g_round_ended", 0),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_round_start_time", 0),
        (try_end),
        (assign, "$my_team_at_start_of_round", -1),
        (assign, "$g_flag_is_not_ready", 0),
        (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_determine_team_flags", 0),
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_number_of_flags", 0),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
            (entry_point_get_position, pos1, 66),
            (set_spawn_position, pos1),
            (spawn_scene_prop, "spr_headquarters_pole_code_only", 0),
            (position_move_z, pos1, 900),
            (set_spawn_position, pos1),
            (spawn_scene_prop, "$team_1_flag_scene_prop", 0),
            (store_add, ":var_0", 146, "$g_number_of_flags"),
            (troop_set_slot, "trp_multiplayer_data", ":var_0", 1),
        (try_end),
        (val_add, "$g_number_of_flags", 1),
        (try_begin),
            (multiplayer_is_server),
            (scene_prop_get_num_instances, ":var_1", "spr_belfry_a"),
            (try_for_range, ":var_2", 0, ":var_1"),
                (scene_prop_get_instance, ":var_3", "spr_belfry_a", ":var_2"),
                (scene_prop_set_slot, ":var_3", 5, 1),
            (try_end),
            (scene_prop_get_num_instances, ":var_1", "spr_belfry_b"),
            (try_for_range, ":var_2", 0, ":var_1"),
                (scene_prop_get_instance, ":var_3", "spr_belfry_b", ":var_2"),
                (scene_prop_set_slot, ":var_3", 5, 1),
            (try_end),
            (call_script, "script_move_belfries_to_their_first_entry_point", "spr_belfry_a"),
            (call_script, "script_move_belfries_to_their_first_entry_point", "spr_belfry_b"),
            (scene_prop_get_num_instances, ":var_1", "spr_belfry_a"),
            (try_for_range, ":var_2", 0, ":var_1"),
                (scene_prop_get_instance, ":var_3", "spr_belfry_a", ":var_2"),
                (scene_prop_set_slot, ":var_3", 3, 0),
                (scene_prop_set_slot, ":var_3", 4, 0),
            (try_end),
            (scene_prop_get_num_instances, ":var_1", "spr_belfry_b"),
            (try_for_range, ":var_2", 0, ":var_1"),
                (scene_prop_get_instance, ":var_3", "spr_belfry_b", ":var_2"),
                (scene_prop_set_slot, ":var_3", 3, 0),
                (scene_prop_set_slot, ":var_3", 4, 0),
            (try_end),
            (scene_prop_get_num_instances, ":var_1", "spr_belfry_a"),
            (try_for_range, ":var_2", 0, ":var_1"),
                (scene_prop_get_instance, ":var_3", "spr_belfry_a", ":var_2"),
                (scene_prop_set_slot, ":var_3", 5, 0),
            (try_end),
            (scene_prop_get_num_instances, ":var_1", "spr_belfry_b"),
            (try_for_range, ":var_2", 0, ":var_1"),
                (scene_prop_get_instance, ":var_3", "spr_belfry_b", ":var_2"),
                (scene_prop_set_slot, ":var_3", 5, 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
        (try_begin),
            (neg|ge, "$my_team_at_start_of_round", 0),
            (multiplayer_get_my_player, ":var_1"),
            (ge, ":var_1", 0),
            (player_get_agent_id, ":var_2", ":var_1"),
            (eq, ":var_2", ":var_0"),
            (ge, ":var_2", 0),
            (agent_get_team, "$my_team_at_start_of_round", ":var_2"),
        (try_end),
        (try_begin),
            (neg|multiplayer_is_server),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (assign, "$g_round_ended", 0),
                (assign, "$g_my_spawn_count", 0),
                (call_script, "script_initialize_all_scene_prop_slots"),
                (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
                (call_script, "script_initialize_objects_clients"),
            (try_end),
        (try_end),
        (try_begin),
            (multiplayer_get_my_player, ":var_1"),
            (ge, ":var_1", 0),
            (player_get_agent_id, ":var_2", ":var_1"),
            (eq, ":var_2", ":var_0"),
            (val_add, "$g_my_spawn_count", 1),
            (try_begin),
                (ge, "$g_my_spawn_count", "$g_multiplayer_number_of_respawn_count"),
                (gt, "$g_multiplayer_number_of_respawn_count", 0),
                (multiplayer_get_my_player, ":var_1"),
                (player_get_team_no, ":var_3", ":var_1"),
                (eq, ":var_3", 0),
                (assign, "$g_my_spawn_count", 999),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (neg|ge, "$my_team_at_start_of_round", 0),
            (multiplayer_get_my_player, ":var_2"),
            (ge, ":var_2", 0),
            (player_get_agent_id, ":var_3", ":var_2"),
            (ge, ":var_3", 0),
            (agent_get_team, "$my_team_at_start_of_round", ":var_3"),
        (try_end),
        (try_begin),
            (multiplayer_is_server),
            (agent_is_human, ":var_0"),
            (neg|agent_is_non_player, ":var_0"),
            (agent_get_player_id, ":var_4", ":var_0"),
            (player_set_slot, ":var_4", 0, 0),
        (try_end),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (try_for_range, ":var_0", 0, "$g_number_of_flags"),
            (store_add, ":var_1", 156, ":var_0"),
            (troop_get_slot, ":var_2", "trp_multiplayer_data", ":var_1"),
            (store_div, ":var_3", ":var_2", 100),
            (store_mod, ":var_4", ":var_2", 100),
            (assign, ":var_5", 0),
            (assign, ":var_6", 0),
            (scene_prop_get_instance, ":var_7", "spr_headquarters_pole_code_only", ":var_0"),
            (prop_instance_get_position, pos0, ":var_7"),
            (get_max_players, ":var_8"),
            (try_for_range, ":var_9", 0, ":var_8"),
                (player_is_active, ":var_9"),
                (player_get_agent_id, ":var_10", ":var_9"),
                (ge, ":var_10", 0),
                (agent_is_alive, ":var_10"),
                (agent_get_team, ":var_11", ":var_10"),
                (agent_get_position, pos1, ":var_10"),
                (get_sq_distance_between_positions, ":var_12", pos0, pos1),
                (get_sq_distance_between_position_heights, ":var_13", pos0, pos1),
                (val_add, ":var_12", ":var_13"),
                (neg|ge, ":var_12", 1600),
                (try_begin),
                    (eq, ":var_11", 0),
                    (val_add, ":var_5", 1),
                (else_try),
                    (eq, ":var_11", 1),
                    (val_add, ":var_6", 1),
                (try_end),
            (try_end),
            (try_begin),
                (this_or_next|neg|eq, ":var_3", ":var_5"),
                (neg|eq, ":var_4", ":var_6"),
                (store_add, ":var_14", 176, ":var_0"),
                (troop_get_slot, ":var_15", "trp_multiplayer_data", ":var_14"),
                (store_mod, ":var_16", ":var_15", 100),
                (store_div, ":var_17", ":var_15", 100),
                (try_begin),
                    (eq, ":var_4", 0),
                    (gt, ":var_6", 0),
                    (eq, ":var_5", 0),
                    (assign, ":var_18", 2),
                    (store_mul, ":var_19", ":var_18", 100),
                    (troop_set_slot, "trp_multiplayer_data", ":var_14", ":var_19"),
                    (this_or_next|neg|eq, ":var_17", ":var_18"),
                    (ge, ":var_16", 25),
                    (store_mul, ":var_20", ":var_18", 100),
                    (val_add, ":var_20", ":var_0"),
                (try_end),
                (try_begin),
                    (store_mul, ":var_2", ":var_5", 100),
                    (val_add, ":var_2", ":var_6"),
                    (troop_set_slot, "trp_multiplayer_data", ":var_1", ":var_2"),
                    (get_max_players, ":var_8"),
                    (call_script, "script_set_num_agents_around_flag", ":var_0", ":var_2"),
                    (try_for_range, ":var_9", 1, ":var_8"),
                        (player_is_active, ":var_9"),
                        (multiplayer_send_2_int_to_player, ":var_9", 73, ":var_0", ":var_2"),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_for_range, ":var_0", 0, "$g_number_of_flags"),
            (eq, "$g_round_ended", 0),
            (eq, "$g_flag_is_not_ready", 0),
            (scene_prop_get_instance, ":var_7", "spr_headquarters_pole_code_only", ":var_0"),
            (prop_instance_get_position, pos0, ":var_7"),
            (try_begin),
                (scene_prop_get_instance, ":var_21", "$team_1_flag_scene_prop", ":var_0"),
                (prop_instance_get_position, pos1, ":var_21"),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_12", pos0, pos1),
                    (neg|ge, ":var_12", 400),
                    (prop_instance_is_animating, ":var_22", ":var_21"),
                    (eq, ":var_22", 1),
                    (assign, "$g_winner_team", 1),
                    (prop_instance_stop_animating, ":var_21"),
                    (get_max_players, ":var_8"),
                    (call_script, "script_draw_this_round", "$g_winner_team"),
                    (try_for_range, ":var_9", 1, ":var_8"),
                        (player_is_active, ":var_9"),
                        (multiplayer_send_int_to_player, ":var_9", 69, "$g_winner_team"),
                    (try_end),
                    (assign, "$g_flag_is_not_ready", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, ":var_0", "$g_multiplayer_num_bots_team_1"),
        (assign, ":var_1", "$g_multiplayer_num_bots_team_2"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (try_begin),
            (this_or_next|eq, ":var_0", 0),
            (eq, ":var_1", 0),
            (store_mission_timer_a, ":var_5"),
            (val_sub, ":var_5", "$g_round_start_time"),
            (neg|gt, ":var_5", 2),
            (store_mission_timer_a, "$g_round_start_time"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_flag_is_not_ready", 0),
        (store_mission_timer_a, ":var_0"),
        (store_sub, ":var_1", ":var_0", "$g_round_start_time"),
        (ge, ":var_1", "$g_multiplayer_round_max_seconds"),
    ],
    [
        (assign, ":var_0", 0),
        (store_add, ":var_1", 156, ":var_0"),
        (troop_get_slot, ":var_2", "trp_multiplayer_data", ":var_1"),
        (store_mod, ":var_3", ":var_2", 100),
        (try_begin),
            (eq, ":var_3", 0),
            (store_mission_timer_a, "$g_round_finish_time"),
            (assign, "$g_round_ended", 1),
            (assign, "$g_flag_is_not_ready", 1),
            (assign, "$g_winner_team", 0),
            (get_max_players, ":var_4"),
            (call_script, "script_draw_this_round", "$g_winner_team"),
            (try_for_range, ":var_5", 1, ":var_4"),
                (player_is_active, ":var_5"),
                (multiplayer_send_int_to_player, ":var_5", 69, "$g_winner_team"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_range, ":var_0", 0, "$g_number_of_flags"),
            (store_add, ":var_1", 176, ":var_0"),
            (troop_get_slot, ":var_2", "trp_multiplayer_data", ":var_1"),
            (store_mod, ":var_3", ":var_2", 100),
            (try_begin),
                (ge, ":var_2", 100),
                (neg|ge, ":var_3", 25),
                (val_add, ":var_2", 1),
                (troop_set_slot, "trp_multiplayer_data", ":var_1", ":var_2"),
            (try_end),
        (try_end),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
    ],
    [
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_5", ":var_0", ":var_1"),
        (assign, ":var_6", 0),
        (try_begin),
            (try_begin),
                (store_mul, ":var_7", "$g_multiplayer_auto_team_balance_limit", -1),
                (neg|gt, ":var_5", ":var_7"),
                (store_div, ":var_6", ":var_5", -2),
            (else_try),
                (ge, ":var_5", "$g_multiplayer_auto_team_balance_limit"),
                (store_div, ":var_6", ":var_5", 2),
            (try_end),
        (try_end),
        (try_begin),
            (gt, ":var_6", 0),
            (try_begin),
                (eq, "$g_team_balance_next_round", 0),
                (assign, "$g_team_balance_next_round", 1),
                (call_script, "script_show_multiplayer_message", 3, 0),
                (get_max_players, ":var_2"),
                (try_for_range, ":var_8", 1, ":var_2"),
                    (player_is_active, ":var_8"),
                    (multiplayer_send_int_to_player, ":var_8", 68, 3),
                (try_end),
                (call_script, "script_warn_player_about_auto_team_balance"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 3.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 1),
        (store_mission_timer_a, ":var_0"),
        (val_sub, ":var_0", "$g_round_finish_time"),
        (ge, ":var_0", "$g_multiplayer_respawn_period"),
    ],
    [
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_5", ":var_0", ":var_1"),
        (assign, ":var_6", 0),
        (try_begin),
            (try_begin),
                (store_mul, ":var_7", "$g_multiplayer_auto_team_balance_limit", -1),
                (neg|gt, ":var_5", ":var_7"),
                (store_div, ":var_6", ":var_5", -2),
                (assign, ":var_8", 1),
                (assign, ":var_9", 0),
            (else_try),
                (ge, ":var_5", "$g_multiplayer_auto_team_balance_limit"),
                (store_div, ":var_6", ":var_5", 2),
                (assign, ":var_8", 0),
                (assign, ":var_9", 1),
            (try_end),
        (try_end),
        (try_begin),
            (gt, ":var_6", 0),
            (try_begin),
                (try_for_range, ":var_10", 0, ":var_6"),
                    (assign, ":var_11", 0),
                    (assign, ":var_12", -1),
                    (get_max_players, ":var_2"),
                    (try_for_range, ":var_13", 0, ":var_2"),
                        (player_is_active, ":var_13"),
                        (player_get_team_no, ":var_4", ":var_13"),
                        (eq, ":var_4", ":var_8"),
                        (player_get_slot, ":var_14", ":var_13", 21),
                        (try_begin),
                            (gt, ":var_14", ":var_11"),
                            (assign, ":var_11", ":var_14"),
                            (assign, ":var_12", ":var_13"),
                        (try_end),
                    (try_end),
                    (try_begin),
                        (ge, ":var_12", 0),
                        (try_begin),
                            (player_get_agent_id, ":var_15", ":var_12"),
                            (ge, ":var_15", 0),
                            (agent_is_alive, ":var_15"),
                            (player_get_kill_count, ":var_16", ":var_12"),
                            (val_add, ":var_16", 1),
                            (player_set_kill_count, ":var_12", ":var_16"),
                            (player_get_death_count, ":var_17", ":var_12"),
                            (val_sub, ":var_17", 1),
                            (player_set_death_count, ":var_12", ":var_17"),
                            (player_get_score, ":var_18", ":var_12"),
                            (val_add, ":var_18", 1),
                            (player_set_score, ":var_12", ":var_18"),
                            (try_for_range, ":var_13", 1, ":var_2"),
                                (player_is_active, ":var_13"),
                                (multiplayer_send_4_int_to_player, ":var_13", 86, ":var_12", ":var_18", ":var_16", ":var_17"),
                            (try_end),
                            (player_get_value_of_original_items, ":var_19", ":var_12"),
                            (player_get_gold, ":var_20", ":var_12"),
                            (val_add, ":var_20", ":var_19"),
                            (player_set_gold, ":var_12", ":var_20", 15000),
                        (try_end),
                        (player_set_troop_id, ":var_12", -1),
                        (player_set_team_no, ":var_12", ":var_9"),
                        (multiplayer_send_message_to_player, ":var_12", 79),
                    (try_end),
                (try_end),
                (call_script, "script_show_multiplayer_message", 2, 0),
                (multiplayer_get_my_player, ":var_21"),
                (get_max_players, ":var_2"),
                (try_for_range, ":var_13", 0, ":var_2"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_21", ":var_13"),
                    (multiplayer_send_int_to_player, ":var_13", 68, 2),
                (try_end),
                (assign, "$g_team_balance_next_round", 0),
            (try_end),
        (try_end),
        (assign, "$g_team_balance_next_round", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_set_slot, ":var_13", 0, 0),
            (player_set_slot, ":var_13", 25, 0),
            (player_get_agent_id, ":var_22", ":var_13"),
            (ge, ":var_22", 0),
            (agent_is_alive, ":var_22"),
            (player_save_picked_up_items_for_next_spawn, ":var_13"),
            (player_get_value_of_original_items, ":var_19", ":var_13"),
            (player_set_slot, ":var_13", 1, ":var_19"),
        (try_end),
        (assign, ":var_23", 500),
        (val_mul, ":var_23", "$g_multiplayer_round_earnings_multiplier"),
        (val_div, ":var_23", 100),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_get_gold, ":var_20", ":var_13"),
            (player_get_team_no, ":var_4", ":var_13"),
            (try_begin),
                (this_or_next|eq, ":var_4", 0),
                (eq, ":var_4", 1),
                (val_add, ":var_20", ":var_23"),
            (try_end),
            (try_begin),
                (player_get_slot, ":var_19", ":var_13", 1),
                (store_add, ":var_24", ":var_20", ":var_19"),
                (store_mul, ":var_25", "$g_multiplayer_initial_gold_multiplier", 10),
                (neg|ge, ":var_24", ":var_25"),
                (store_sub, ":var_26", ":var_25", ":var_24"),
                (val_add, ":var_20", ":var_26"),
            (try_end),
            (player_set_gold, ":var_13", ":var_20", 15000),
        (try_end),
        (assign, "$my_team_at_start_of_round", -1),
        (multiplayer_clear_scene),
        (assign, "$g_my_spawn_count", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_set_slot, ":var_13", 39, 0),
        (try_end),
        (call_script, "script_initialize_objects"),
        (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
        (call_script, "script_multiplayer_close_gate_if_it_is_open"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (call_script, "script_move_belfries_to_their_first_entry_point", "spr_belfry_a"),
        (call_script, "script_move_belfries_to_their_first_entry_point", "spr_belfry_b"),
        (scene_prop_get_num_instances, ":var_27", "spr_belfry_a"),
        (try_for_range, ":var_28", 0, ":var_27"),
            (scene_prop_get_instance, ":var_29", "spr_belfry_a", ":var_28"),
            (scene_prop_set_slot, ":var_29", 3, 0),
            (scene_prop_set_slot, ":var_29", 4, 0),
        (try_end),
        (scene_prop_get_num_instances, ":var_27", "spr_belfry_a"),
        (try_for_range, ":var_28", 0, ":var_27"),
            (scene_prop_get_instance, ":var_29", "spr_belfry_a", ":var_28"),
            (scene_prop_set_slot, ":var_29", 5, 0),
        (try_end),
        (scene_prop_get_num_instances, ":var_27", "spr_belfry_b"),
        (try_for_range, ":var_28", 0, ":var_27"),
            (scene_prop_get_instance, ":var_29", "spr_belfry_b", ":var_28"),
            (scene_prop_set_slot, ":var_29", 3, 0),
            (scene_prop_set_slot, ":var_29", 4, 0),
        (try_end),
        (scene_prop_get_num_instances, ":var_27", "spr_belfry_b"),
        (try_for_range, ":var_28", 0, ":var_27"),
            (scene_prop_get_instance, ":var_29", "spr_belfry_b", ":var_28"),
            (scene_prop_set_slot, ":var_29", 5, 0),
        (try_end),
        (try_for_range, ":var_30", 0, "$g_number_of_flags"),
            (scene_prop_get_instance, ":var_31", "spr_headquarters_pole_code_only", ":var_30"),
            (prop_instance_get_position, pos1, ":var_31"),
            (position_move_z, pos1, 900),
            (scene_prop_get_instance, ":var_32", "$team_1_flag_scene_prop", ":var_30"),
            (prop_instance_stop_animating, ":var_32"),
            (prop_instance_set_position, ":var_32", pos1),
        (try_end),
        (assign, "$g_round_ended", 0),
        (store_mission_timer_a, "$g_round_start_time"),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (multiplayer_send_int_to_player, ":var_13", 78, -9999),
        (try_end),
        (assign, "$g_flag_is_not_ready", 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (player_slot_eq, ":var_1", 0, 0),
            (player_get_team_no, ":var_2", ":var_1"),
            (neg|ge, ":var_2", 2),
            (player_get_troop_id, ":var_3", ":var_1"),
            (ge, ":var_3", 0),
            (player_get_agent_id, ":var_4", ":var_1"),
            (assign, ":var_5", 0),
            (assign, ":var_6", 0),
            (assign, ":var_7", 0),
            (try_begin),
                (assign, ":var_8", 0),
                (get_max_players, ":var_0"),
                (try_for_range, ":var_9", 0, ":var_0"),
                    (player_is_active, ":var_9"),
                    (player_get_team_no, ":var_10", ":var_9"),
                    (try_begin),
                        (eq, ":var_10", 0),
                        (val_add, ":var_6", 1),
                    (else_try),
                        (eq, ":var_10", 1),
                        (val_add, ":var_7", 1),
                    (try_end),
                    (val_add, ":var_8", 1),
                (try_end),
                (store_mission_timer_a, ":var_11"),
                (val_sub, ":var_11", "$g_round_start_time"),
                (eq, "$g_round_ended", 0),
                (try_begin),
                    (neg|ge, ":var_4", 0),
                    (try_begin),
                        (eq, ":var_2", 0),
                        (player_get_slot, ":var_12", ":var_1", 28),
                        (store_mission_timer_a, ":var_13"),
                        (store_sub, ":var_14", ":var_13", ":var_12"),
                        (assign, ":var_15", "$g_multiplayer_respawn_period"),
                        (val_add, ":var_15", 27),
                        (neg|ge, ":var_14", ":var_15"),
                        (store_sub, ":var_11", ":var_13", "$g_round_start_time"),
                        (ge, ":var_11", 30),
                        (gt, ":var_8", 2),
                        (store_mul, ":var_16", ":var_6", ":var_7"),
                        (neg|eq, ":var_16", 0),
                        (assign, ":var_5", 0),
                    (else_try),
                        (assign, ":var_5", 1),
                    (try_end),
                (else_try),
                    (agent_get_time_elapsed_since_removed, ":var_14", ":var_4"),
                    (assign, ":var_15", "$g_multiplayer_respawn_period"),
                    (try_begin),
                        (eq, ":var_2", 0),
                        (val_add, ":var_15", 27),
                    (try_end),
                    (this_or_next|gt, ":var_14", ":var_15"),
                    (player_slot_eq, ":var_1", 25, 0),
                    (assign, ":var_5", 1),
                (try_end),
            (try_end),
            (player_get_slot, ":var_17", ":var_1", 39),
            (try_begin),
                (gt, "$g_multiplayer_number_of_respawn_count", 0),
                (try_begin),
                    (eq, ":var_5", 1),
                    (eq, ":var_2", 0),
                    (ge, ":var_17", "$g_multiplayer_number_of_respawn_count"),
                    (assign, ":var_5", 0),
                (else_try),
                    (eq, ":var_5", 1),
                    (eq, ":var_2", 1),
                    (ge, ":var_17", 999),
                    (assign, ":var_5", 0),
                (try_end),
            (try_end),
            (eq, ":var_5", 1),
            (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
            (player_get_slot, ":var_17", ":var_1", 39),
            (val_add, ":var_17", 1),
            (player_set_slot, ":var_1", 39, ":var_17"),
            (try_begin),
                (ge, ":var_17", "$g_multiplayer_number_of_respawn_count"),
                (gt, "$g_multiplayer_number_of_respawn_count", 0),
                (eq, ":var_2", 0),
                (assign, ":var_17", 999),
                (player_set_slot, ":var_1", 39, ":var_17"),
            (try_end),
            (assign, ":var_18", 0),
            (player_get_item_id, ":var_19", ":var_1", 8),
            (try_begin),
                (this_or_next|is_between, ":var_19", "itm_sumpter_horse", "itm_arrows"),
                (this_or_next|eq, ":var_19", "itm_warhorse_sarranid"),
                (eq, ":var_19", "itm_warhorse_steppe"),
                (assign, ":var_18", 1),
            (try_end),
            (try_begin),
                (neg|ge, ":var_11", 20),
                (try_begin),
                    (eq, ":var_2", 0),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_2", 1, ":var_18"),
                    (assign, ":var_20", reg0),
                (else_try),
                    (eq, ":var_2", 1),
                    (assign, ":var_20", 32),
                (try_end),
            (else_try),
                (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_18"),
                (assign, ":var_20", reg0),
            (try_end),
            (player_spawn_new_agent, ":var_1", ":var_20"),
            (player_set_slot, ":var_1", 0, 1),
            (player_set_slot, ":var_1", 25, 1),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (try_for_agents, ":var_3"),
            (agent_is_non_player, ":var_3"),
            (agent_is_human, ":var_3"),
            (assign, ":var_4", 0),
            (try_begin),
                (agent_is_alive, ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (agent_get_time_elapsed_since_removed, ":var_5", ":var_3"),
                (neg|gt, ":var_5", "$g_multiplayer_respawn_period"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (agent_get_team, ":var_6", ":var_3"),
            (try_begin),
                (eq, ":var_6", 0),
                (val_add, ":var_1", 1),
            (else_try),
                (eq, ":var_6", 1),
                (val_add, ":var_2", 1),
            (try_end),
        (try_end),
        (store_sub, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1", ":var_1"),
        (store_sub, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2", ":var_2"),
        (val_max, "$g_multiplayer_num_bots_required_team_1", 0),
        (val_max, "$g_multiplayer_num_bots_required_team_2", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (this_or_next|eq, "$g_multiplayer_game_type", 3),
                (eq, "$g_multiplayer_game_type", 6),
                (team_get_score, ":var_1", 0),
                (team_get_score, ":var_2", 1),
                (store_add, ":var_3", ":var_1", ":var_2"),
                (eq, ":var_3", 0),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (neg|ge, ":var_4", 20),
                (assign, ":var_5", 0),
            (else_try),
                (assign, ":var_5", 1),
            (try_end),
            (eq, ":var_5", 1),
            (store_random_in_range, ":var_6", 0, ":var_0"),
            (val_sub, ":var_6", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_6", 0),
                (assign, ":var_7", 0),
            (else_try),
                (assign, ":var_7", 1),
            (try_end),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (eq, "$g_multiplayer_game_type", 3),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (try_begin),
                    (neg|gt, ":var_4", 20),
                    (assign, ":var_8", 0),
                (else_try),
                    (assign, ":var_8", 1),
                (try_end),
            (else_try),
                (assign, ":var_8", 1),
            (try_end),
            (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":var_7", ":var_8"),
            (assign, ":var_9", reg0),
            (assign, ":var_10", reg1),
            (team_get_faction, ":var_11", ":var_7"),
            (assign, ":var_12", 0),
            (try_for_range, ":var_13", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_14", ":var_13"),
                (eq, ":var_14", ":var_11"),
                (val_add, ":var_12", 1),
            (try_end),
            (assign, ":var_15", 0),
            (get_max_players, ":var_16"),
            (try_for_range, ":var_17", 0, ":var_16"),
                (player_is_active, ":var_17"),
                (player_get_team_no, ":var_18", ":var_17"),
                (eq, ":var_7", ":var_18"),
                (assign, ":var_19", 0),
                (store_add, ":var_20", 35, ":var_12"),
                (try_for_range, ":var_21", 35, ":var_20"),
                    (player_slot_ge, ":var_17", ":var_21", 1),
                    (assign, ":var_19", 1),
                    (assign, ":var_20", 0),
                (try_end),
                (ge, ":var_19", 1),
                (val_add, ":var_15", 1),
            (try_end),
            (try_begin),
                (this_or_next|ge, ":var_10", 0),
                (eq, ":var_15", 0),
                (troop_get_inventory_slot, ":var_22", ":var_9", 8),
                (try_begin),
                    (ge, ":var_22", 0),
                    (assign, ":var_23", 1),
                (else_try),
                    (assign, ":var_23", 0),
                (try_end),
                (try_begin),
                    (eq, "$g_multiplayer_game_type", 6),
                    (store_mission_timer_a, ":var_4"),
                    (val_sub, ":var_4", "$g_round_start_time"),
                    (try_begin),
                        (neg|ge, ":var_4", 20),
                        (try_begin),
                            (eq, ":var_7", 0),
                            (call_script, "script_multiplayer_find_spawn_point", ":var_7", 1, ":var_23"),
                        (else_try),
                            (assign, reg0, 32),
                        (try_end),
                    (else_try),
                        (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                    (try_end),
                (else_try),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, reg0, 0),
                    (else_try),
                        (assign, reg0, 32),
                    (try_end),
                (else_try),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                (try_end),
                (store_current_scene, ":var_24"),
                (modify_visitors_at_site, ":var_24"),
                (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_7", ":var_10"),
                (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
                (try_begin),
                    (eq, ":var_7", 0),
                    (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
                (else_try),
                    (eq, ":var_7", 1),
                    (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_agents, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_group, ":var_1", ":var_0"),
            (try_begin),
                (neg|player_is_active, ":var_1"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (else_try),
                (player_get_team_no, ":var_2", ":var_1"),
                (agent_get_team, ":var_3", ":var_0"),
                (neg|eq, ":var_2", ":var_3"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_game_type", 2),
            (this_or_next|eq, "$g_multiplayer_game_type", 3),
            (eq, "$g_multiplayer_game_type", 6),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (store_mission_timer_a, ":var_1"),
                (val_sub, ":var_1", "$g_round_finish_time"),
                (store_sub, ":var_2", "$g_multiplayer_respawn_period", 1),
                (ge, ":var_1", ":var_2"),
                (store_mission_timer_a, ":var_3"),
                (try_begin),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (assign, ":var_4", 90),
                (else_try),
                    (assign, ":var_4", 120),
                (try_end),
                (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (gt, ":var_3", ":var_6"),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 1),
        (else_try),
            (neg|eq, "$g_multiplayer_game_type", 2),
            (neg|eq, "$g_multiplayer_game_type", 3),
            (neg|eq, "$g_multiplayer_game_type", 6),
            (neg|eq, "$g_multiplayer_game_type", 5),
            (store_mission_timer_a, ":var_3"),
            (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_3", ":var_5"),
            (assign, ":var_0", 1),
        (else_try),
            (team_get_score, ":var_7", 0),
            (team_get_score, ":var_8", 1),
            (try_begin),
                (neg|eq, "$g_multiplayer_game_type", 5),
                (try_begin),
                    (this_or_next|ge, ":var_7", "$g_multiplayer_game_max_points"),
                    (ge, ":var_8", "$g_multiplayer_game_max_points"),
                    (assign, ":var_0", 1),
                (try_end),
            (else_try),
                (assign, ":var_9", 0),
                (get_max_players, ":var_10"),
                (try_for_range, ":var_11", 0, ":var_10"),
                    (player_is_active, ":var_11"),
                    (player_get_agent_id, ":var_12", ":var_11"),
                    (ge, ":var_12", 0),
                    (neg|agent_is_non_player, ":var_12"),
                    (assign, ":var_9", 1),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_9", 1),
                (this_or_next|neg|gt, ":var_7", 0),
                (neg|gt, ":var_8", 0),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_round_time_counter"),
        (start_presentation, "prsnt_multiplayer_team_score_display"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"multiplayer_bt", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 2),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (assign, "$g_waiting_for_confirmation_to_terminate", 0),
        (assign, "$g_round_ended", 0),
        (assign, "$g_battle_death_mode_started", 0),
        (assign, "$g_reduced_waiting_seconds", 0),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$server_mission_timer_while_player_joined", 0),
            (assign, "$g_round_start_time", 0),
        (try_end),
        (assign, "$my_team_at_start_of_round", -1),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_determine_team_flags", 0),
        (call_script, "script_determine_team_flags", 1),
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
            (entry_point_get_position, pos0, 67),
            (position_set_z_to_ground_level, pos0),
            (position_move_z, pos0, -2000),
            (position_move_x, pos0, 100),
            (set_spawn_position, pos0),
            (spawn_scene_prop, "spr_headquarters_pole_code_only", 0),
            (position_move_x, pos0, -200),
            (set_spawn_position, pos0),
            (spawn_scene_prop, "spr_headquarters_pole_code_only", 0),
            (scene_prop_get_instance, ":var_0", "spr_headquarters_pole_code_only", 0),
            (prop_instance_get_position, pos0, ":var_0"),
            (spawn_scene_prop, "$team_1_flag_scene_prop", 0),
            (position_move_z, pos0, 100),
            (prop_instance_set_position, reg0, pos0),
            (scene_prop_get_instance, ":var_1", "spr_headquarters_pole_code_only", 1),
            (prop_instance_get_position, pos0, ":var_1"),
            (spawn_scene_prop, "$team_2_flag_scene_prop", 0),
            (position_move_z, pos0, 100),
            (prop_instance_set_position, reg0, pos0),
            (assign, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1"),
            (assign, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2"),
        (try_end),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
        (try_begin),
            (neg|ge, "$my_team_at_start_of_round", 0),
            (multiplayer_get_my_player, ":var_1"),
            (ge, ":var_1", 0),
            (player_get_agent_id, ":var_2", ":var_1"),
            (eq, ":var_2", ":var_0"),
            (ge, ":var_2", 0),
            (agent_get_team, "$my_team_at_start_of_round", ":var_2"),
        (try_end),
        (call_script, "script_calculate_new_death_waiting_time_at_death_mod"),
        (try_begin),
            (neg|multiplayer_is_server),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (assign, "$g_round_ended", 0),
                (call_script, "script_initialize_all_scene_prop_slots"),
                (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
                (call_script, "script_initialize_objects_clients"),
                (try_begin),
                    (eq, "$g_team_balance_next_round", 1),
                    (assign, "$g_team_balance_next_round", 0),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (neg|ge, "$my_team_at_start_of_round", 0),
            (multiplayer_get_my_player, ":var_2"),
            (ge, ":var_2", 0),
            (player_get_agent_id, ":var_3", ":var_2"),
            (ge, ":var_3", 0),
            (agent_get_team, "$my_team_at_start_of_round", ":var_3"),
        (try_end),
        (try_begin),
            (agent_is_human, ":var_0"),
            (assign, ":var_4", 0),
            (assign, ":var_5", 0),
            (try_for_agents, ":var_6"),
                (agent_is_human, ":var_6"),
                (try_begin),
                    (agent_is_alive, ":var_6"),
                    (agent_get_team, ":var_7", ":var_6"),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (val_add, ":var_4", 1),
                    (else_try),
                        (eq, ":var_7", 1),
                        (val_add, ":var_5", 1),
                    (try_end),
                (try_end),
            (try_end),
            (try_begin),
                (eq, "$g_round_ended", 0),
                (try_begin),
                    (this_or_next|eq, ":var_4", 0),
                    (eq, ":var_5", 0),
                    (assign, "$g_winner_team", -1),
                    (assign, reg0, "$g_multiplayer_respawn_period"),
                    (try_begin),
                        (eq, ":var_4", 0),
                        (try_begin),
                            (neg|eq, ":var_5", 0),
                            (team_get_score, ":var_8", 1),
                            (val_add, ":var_8", 1),
                            (team_set_score, 1, ":var_8"),
                            (assign, "$g_winner_team", 1),
                        (try_end),
                        (call_script, "script_show_multiplayer_message", 12, "$g_winner_team"),
                        (call_script, "script_check_achievement_last_man_standing", "$g_winner_team"),
                    (else_try),
                        (try_begin),
                            (neg|eq, ":var_4", 0),
                            (team_get_score, ":var_9", 0),
                            (val_add, ":var_9", 1),
                            (team_set_score, 0, ":var_9"),
                            (assign, "$g_winner_team", 0),
                        (try_end),
                        (call_script, "script_show_multiplayer_message", 12, "$g_winner_team"),
                        (call_script, "script_check_achievement_last_man_standing", "$g_winner_team"),
                    (try_end),
                    (store_mission_timer_a, "$g_round_finish_time"),
                    (assign, "$g_round_ended", 1),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (multiplayer_is_server),
            (agent_is_human, ":var_0"),
            (neg|agent_is_non_player, ":var_0"),
            (ge, ":var_0", 0),
            (agent_get_player_id, ":var_10", ":var_0"),
            (ge, ":var_10", 0),
            (set_fixed_point_multiplier, 100),
            (agent_get_player_id, ":var_10", ":var_0"),
            (agent_get_position, pos0, ":var_0"),
            (position_get_x, ":var_11", pos0),
            (position_get_y, ":var_12", pos0),
            (position_get_z, ":var_13", pos0),
            (player_set_slot, ":var_10", 29, ":var_11"),
            (player_set_slot, ":var_10", 30, ":var_12"),
            (player_set_slot, ":var_10", 31, ":var_13"),
        (try_end),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_sub, ":var_1", ":var_0", "$g_round_start_time"),
        (ge, ":var_1", "$g_multiplayer_round_max_seconds"),
        (assign, ":var_2", 0),
        (try_begin),
            (eq, "$g_battle_death_mode_started", 2),
            (scene_prop_get_instance, ":var_3", "spr_headquarters_pole_code_only", 0),
            (scene_prop_get_instance, ":var_4", "spr_headquarters_pole_code_only", 1),
            (scene_prop_get_instance, ":var_5", "$team_1_flag_scene_prop", 0),
            (scene_prop_get_instance, ":var_6", "$team_2_flag_scene_prop", 0),
            (prop_instance_get_position, pos1, ":var_3"),
            (prop_instance_get_position, pos2, ":var_4"),
            (prop_instance_get_position, pos3, ":var_5"),
            (prop_instance_get_position, pos4, ":var_6"),
            (get_distance_between_positions, ":var_7", pos1, pos3),
            (get_distance_between_positions, ":var_8", pos2, pos4),
            (store_add, ":var_9", ":var_7", 50),
            (store_add, ":var_10", ":var_8", 50),
            (try_begin),
                (neg|gt, ":var_7", ":var_10"),
                (prop_instance_is_animating, ":var_11", ":var_5"),
                (eq, ":var_11", 1),
                (prop_instance_get_animation_target_position, 5, ":var_5"),
                (position_get_z, ":var_12", pos5),
                (position_get_z, ":var_13", pos3),
                (ge, ":var_12", ":var_13"),
                (assign, ":var_2", 1),
            (try_end),
            (try_begin),
                (neg|gt, ":var_8", ":var_9"),
                (prop_instance_is_animating, ":var_11", ":var_6"),
                (eq, ":var_11", 1),
                (prop_instance_get_animation_target_position, 5, ":var_6"),
                (position_get_z, ":var_12", pos5),
                (position_get_z, ":var_14", pos4),
                (ge, ":var_12", ":var_14"),
                (assign, ":var_2", 1),
            (try_end),
        (try_end),
        (eq, ":var_2", 0),
    ],
    [
        (store_mission_timer_a, "$g_round_finish_time"),
        (assign, "$g_round_ended", 1),
        (assign, "$g_winner_team", -1),
        (try_begin),
            (eq, "$g_battle_death_mode_started", 2),
            (scene_prop_get_instance, ":var_0", "spr_headquarters_pole_code_only", 0),
            (scene_prop_get_instance, ":var_1", "spr_headquarters_pole_code_only", 1),
            (scene_prop_get_instance, ":var_2", "$team_1_flag_scene_prop", 0),
            (scene_prop_get_instance, ":var_3", "$team_2_flag_scene_prop", 0),
            (prop_instance_get_position, pos1, ":var_0"),
            (prop_instance_get_position, pos2, ":var_1"),
            (prop_instance_get_position, pos3, ":var_2"),
            (prop_instance_get_position, pos4, ":var_3"),
            (get_distance_between_positions, ":var_4", pos1, pos3),
            (get_distance_between_positions, ":var_5", pos2, pos4),
            (try_begin),
                (ge, ":var_4", ":var_5"),
                (store_sub, ":var_6", ":var_4", ":var_5"),
                (ge, ":var_6", 50),
                (assign, "$g_winner_team", 0),
            (else_try),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (ge, ":var_6", 50),
                (assign, "$g_winner_team", 1),
            (try_end),
        (try_end),
        (multiplayer_get_my_player, ":var_7"),
        (call_script, "script_draw_this_round", "$g_winner_team"),
        (get_max_players, ":var_8"),
        (try_for_range, ":var_9", 1, ":var_8"),
            (player_is_active, ":var_9"),
            (neg|eq, ":var_9", ":var_7"),
            (multiplayer_send_int_to_player, ":var_9", 69, "$g_winner_team"),
        (try_end),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
    ],
    [
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_5", ":var_0", ":var_1"),
        (assign, ":var_6", 0),
        (try_begin),
            (try_begin),
                (store_mul, ":var_7", "$g_multiplayer_auto_team_balance_limit", -1),
                (neg|gt, ":var_5", ":var_7"),
                (store_div, ":var_6", ":var_5", -2),
            (else_try),
                (ge, ":var_5", "$g_multiplayer_auto_team_balance_limit"),
                (store_div, ":var_6", ":var_5", 2),
            (try_end),
        (try_end),
        (try_begin),
            (gt, ":var_6", 0),
            (try_begin),
                (eq, "$g_team_balance_next_round", 0),
                (assign, "$g_team_balance_next_round", 1),
                (call_script, "script_show_multiplayer_message", 3, 0),
                (get_max_players, ":var_2"),
                (try_for_range, ":var_8", 1, ":var_2"),
                    (player_is_active, ":var_8"),
                    (multiplayer_send_int_to_player, ":var_8", 68, 3),
                (try_end),
                (call_script, "script_warn_player_about_auto_team_balance"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_battle_death_mode_started", 0),
        (store_mission_timer_a, ":var_0"),
        (val_sub, ":var_0", "$g_round_start_time"),
        (store_div, "$g_multiplayer_round_max_seconds_div_2", "$g_multiplayer_round_max_seconds", 2),
        (ge, ":var_0", "$g_multiplayer_round_max_seconds_div_2"),
    ],
    [
        (call_script, "script_calculate_new_death_waiting_time_at_death_mod"),
        (assign, "$g_battle_death_mode_started", 1),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_battle_death_mode_started", 1),
        (store_mission_timer_a, ":var_0"),
        (val_sub, ":var_0", "$g_death_mode_part_1_start_time"),
        (store_add, ":var_1", "$g_battle_waiting_seconds", "$g_reduced_waiting_seconds"),
        (ge, ":var_0", ":var_1"),
        (store_mission_timer_a, ":var_2"),
        (store_sub, ":var_3", ":var_2", "$g_round_start_time"),
        (store_sub, ":var_4", "$g_multiplayer_round_max_seconds", 15),
        (neg|ge, ":var_3", ":var_4"),
    ],
    [
        (assign, "$g_battle_death_mode_started", 2),
        (call_script, "script_start_death_mode"),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 1, ":var_0"),
            (player_is_active, ":var_1"),
            (multiplayer_send_int_to_player, ":var_1", 80),
        (try_end),
        (scene_prop_get_instance, ":var_2", "spr_headquarters_pole_code_only", 0),
        (scene_prop_get_instance, ":var_3", "spr_headquarters_pole_code_only", 1),
        (scene_prop_get_instance, ":var_4", "$team_1_flag_scene_prop", 0),
        (scene_prop_get_instance, ":var_5", "$team_2_flag_scene_prop", 0),
        (store_random_in_range, "$g_random_entry_point", 0, 3),
        (val_add, "$g_random_entry_point", 67),
        (entry_point_get_position, pos0, "$g_random_entry_point"),
        (position_set_z_to_ground_level, pos0),
        (position_move_x, pos0, 100),
        (prop_instance_set_position, ":var_2", pos0),
        (position_move_x, pos0, -200),
        (prop_instance_set_position, ":var_3", pos0),
        (prop_instance_get_position, pos0, ":var_2"),
        (position_move_z, pos0, 100),
        (prop_instance_set_position, ":var_4", pos0),
        (prop_instance_get_position, pos0, ":var_3"),
        (position_move_z, pos0, 100),
        (prop_instance_set_position, ":var_5", pos0),
        (start_presentation, "prsnt_multiplayer_flag_projection_display_bt"),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_battle_death_mode_started", 1),
        (store_mission_timer_a, ":var_0"),
        (val_sub, ":var_0", "$g_death_mode_part_1_start_time"),
        (store_add, ":var_1", "$g_battle_waiting_seconds", "$g_reduced_waiting_seconds"),
        (val_sub, ":var_1", 20),
        (ge, ":var_0", ":var_1"),
    ],
    [
        (assign, ":var_0", 0),
        (try_for_agents, ":var_1"),
            (eq, ":var_0", 0),
            (agent_is_human, ":var_1"),
            (try_for_agents, ":var_2"),
                (agent_is_human, ":var_2"),
                (neg|eq, ":var_1", ":var_2"),
                (agent_get_team, ":var_3", ":var_1"),
                (agent_get_team, ":var_4", ":var_2"),
                (neg|eq, ":var_3", ":var_4"),
                (agent_get_position, pos1, ":var_1"),
                (agent_get_position, pos2, ":var_2"),
                (get_sq_distance_between_positions_in_meters, ":var_5", pos1, pos2),
                (neg|gt, ":var_5", 49),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (val_add, "$g_reduced_waiting_seconds", 3),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_battle_death_mode_started", 1),
        (store_mission_timer_a, ":var_0"),
        (store_sub, ":var_1", ":var_0", "$g_round_start_time"),
        (store_sub, ":var_2", "$g_multiplayer_round_max_seconds", 66),
        (ge, ":var_1", ":var_2"),
        (store_mission_timer_a, ":var_0"),
        (store_sub, ":var_1", ":var_0", "$g_round_start_time"),
        (store_sub, ":var_3", "$g_multiplayer_round_max_seconds", 24),
        (neg|gt, ":var_1", ":var_3"),
    ],
    [
        (val_add, "$g_reduced_waiting_seconds", 1),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_battle_death_mode_started", 2),
    ],
    [
        (set_fixed_point_multiplier, 100),
        (scene_prop_get_instance, ":var_0", "spr_headquarters_pole_code_only", 0),
        (scene_prop_get_instance, ":var_1", "spr_headquarters_pole_code_only", 1),
        (scene_prop_get_instance, ":var_2", "$team_1_flag_scene_prop", 0),
        (scene_prop_get_instance, ":var_3", "$team_2_flag_scene_prop", 0),
        (prop_instance_get_position, pos1, ":var_0"),
        (prop_instance_get_position, pos2, ":var_1"),
        (prop_instance_get_position, pos3, ":var_2"),
        (prop_instance_get_position, pos4, ":var_3"),
        (copy_position, pos7, pos1),
        (position_move_z, pos7, 100),
        (copy_position, pos8, pos2),
        (position_move_z, pos8, 100),
        (get_distance_between_positions, ":var_4", pos1, pos3),
        (get_distance_between_positions, ":var_5", pos2, pos4),
        (assign, ":var_6", 0),
        (assign, ":var_7", 0),
        (get_max_players, ":var_8"),
        (try_for_range, ":var_9", 0, ":var_8"),
            (player_is_active, ":var_9"),
            (player_get_agent_id, ":var_10", ":var_9"),
            (ge, ":var_10", 0),
            (agent_is_human, ":var_10"),
            (agent_is_alive, ":var_10"),
            (agent_get_team, ":var_11", ":var_10"),
            (agent_get_position, pos0, ":var_10"),
            (agent_get_horse, ":var_12", ":var_10"),
            (eq, ":var_12", -1),
            (try_begin),
                (eq, ":var_11", 0),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos1),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (this_or_next|eq, ":var_6", 0),
                        (eq, ":var_6", 1),
                        (assign, ":var_6", 1),
                    (else_try),
                        (assign, ":var_6", -2),
                    (try_end),
                (try_end),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos2),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, ":var_7", -1),
                    (else_try),
                        (eq, ":var_7", 1),
                        (assign, ":var_7", -2),
                    (try_end),
                (try_end),
            (else_try),
                (eq, ":var_11", 1),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos2),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (this_or_next|eq, ":var_7", 0),
                        (eq, ":var_7", 1),
                        (assign, ":var_7", 1),
                    (else_try),
                        (assign, ":var_7", -2),
                    (try_end),
                (try_end),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos1),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (eq, ":var_6", 0),
                        (assign, ":var_6", -1),
                    (else_try),
                        (eq, ":var_6", 1),
                        (assign, ":var_6", -2),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (ge, ":var_4", 800),
            (assign, "$g_winner_team", 0),
            (get_max_players, ":var_8"),
            (call_script, "script_draw_this_round", "$g_winner_team"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_int_to_player, ":var_9", 69, "$g_winner_team"),
            (try_end),
            (team_get_score, ":var_14", 0),
            (call_script, "script_team_set_score", 0, ":var_14"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_2_int_to_player, ":var_9", 72, 0, ":var_14"),
            (try_end),
            (store_mission_timer_a, "$g_round_finish_time"),
            (assign, "$g_round_ended", 1),
        (else_try),
            (ge, ":var_5", 800),
            (assign, "$g_winner_team", 1),
            (get_max_players, ":var_8"),
            (call_script, "script_draw_this_round", "$g_winner_team"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_int_to_player, ":var_9", 69, "$g_winner_team"),
            (try_end),
            (team_get_score, ":var_15", 1),
            (call_script, "script_team_set_score", 1, ":var_15"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_2_int_to_player, ":var_9", 72, 1, ":var_15"),
            (try_end),
            (call_script, "script_show_multiplayer_message", 12, 0),
            (call_script, "script_check_achievement_last_man_standing", "$g_winner_team"),
            (store_mission_timer_a, "$g_round_finish_time"),
            (assign, "$g_round_ended", 1),
        (try_end),
        (try_begin),
            (eq, "$g_round_ended", 0),
            (position_get_z, ":var_16", pos3),
            (prop_instance_is_animating, ":var_17", ":var_2"),
            (try_begin),
                (eq, ":var_6", -2),
                (eq, ":var_17", 1),
                (prop_instance_stop_animating, ":var_2"),
            (else_try),
                (this_or_next|eq, ":var_6", 0),
                (eq, ":var_6", -1),
                (prop_instance_get_animation_target_position, 9, ":var_2"),
                (position_get_z, ":var_18", pos9),
                (this_or_next|eq, ":var_17", 0),
                (gt, ":var_18", ":var_16"),
                (get_distance_between_positions, ":var_19", pos3, pos7),
                (gt, ":var_19", 0),
                (val_mul, ":var_19", 16),
                (prop_instance_animate_to_position, ":var_2", 7, ":var_19"),
            (else_try),
                (eq, ":var_6", 1),
                (prop_instance_get_animation_target_position, 9, ":var_2"),
                (position_get_z, ":var_18", pos9),
                (this_or_next|eq, ":var_17", 0),
                (neg|ge, ":var_18", ":var_16"),
                (copy_position, pos5, pos1),
                (position_move_z, pos5, 800),
                (get_distance_between_positions, ":var_19", pos3, pos5),
                (gt, ":var_19", 0),
                (val_mul, ":var_19", 8),
                (prop_instance_animate_to_position, ":var_2", 5, ":var_19"),
            (try_end),
            (position_get_z, ":var_20", pos4),
            (prop_instance_is_animating, ":var_17", ":var_3"),
            (try_begin),
                (eq, ":var_7", -2),
                (eq, ":var_17", 1),
                (prop_instance_stop_animating, ":var_3"),
            (else_try),
                (this_or_next|eq, ":var_7", 0),
                (eq, ":var_7", -1),
                (prop_instance_get_animation_target_position, 9, ":var_3"),
                (position_get_z, ":var_21", pos9),
                (this_or_next|eq, ":var_17", 0),
                (gt, ":var_21", ":var_20"),
                (get_distance_between_positions, ":var_22", pos4, pos8),
                (gt, ":var_22", 0),
                (val_mul, ":var_22", 16),
                (prop_instance_animate_to_position, ":var_3", 8, ":var_22"),
            (else_try),
                (eq, ":var_7", 1),
                (prop_instance_get_animation_target_position, 9, ":var_3"),
                (position_get_z, ":var_21", pos9),
                (this_or_next|eq, ":var_17", 0),
                (neg|ge, ":var_21", ":var_20"),
                (copy_position, pos6, pos2),
                (position_move_z, pos6, 800),
                (get_distance_between_positions, ":var_22", pos4, pos6),
                (gt, ":var_22", 0),
                (val_mul, ":var_22", 8),
                (prop_instance_animate_to_position, ":var_3", 6, ":var_22"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 3.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 1),
        (store_mission_timer_a, ":var_0"),
        (val_sub, ":var_0", "$g_round_finish_time"),
        (ge, ":var_0", "$g_multiplayer_respawn_period"),
    ],
    [
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_5", ":var_0", ":var_1"),
        (assign, ":var_6", 0),
        (try_begin),
            (try_begin),
                (store_mul, ":var_7", "$g_multiplayer_auto_team_balance_limit", -1),
                (neg|gt, ":var_5", ":var_7"),
                (store_div, ":var_6", ":var_5", -2),
                (assign, ":var_8", 1),
                (assign, ":var_9", 0),
            (else_try),
                (ge, ":var_5", "$g_multiplayer_auto_team_balance_limit"),
                (store_div, ":var_6", ":var_5", 2),
                (assign, ":var_8", 0),
                (assign, ":var_9", 1),
            (try_end),
        (try_end),
        (try_begin),
            (gt, ":var_6", 0),
            (try_begin),
                (try_for_range, ":var_10", 0, ":var_6"),
                    (assign, ":var_11", 0),
                    (assign, ":var_12", -1),
                    (get_max_players, ":var_2"),
                    (try_for_range, ":var_13", 0, ":var_2"),
                        (player_is_active, ":var_13"),
                        (player_get_team_no, ":var_4", ":var_13"),
                        (eq, ":var_4", ":var_8"),
                        (player_get_slot, ":var_14", ":var_13", 21),
                        (try_begin),
                            (gt, ":var_14", ":var_11"),
                            (assign, ":var_11", ":var_14"),
                            (assign, ":var_12", ":var_13"),
                        (try_end),
                    (try_end),
                    (try_begin),
                        (ge, ":var_12", 0),
                        (try_begin),
                            (player_get_agent_id, ":var_15", ":var_12"),
                            (ge, ":var_15", 0),
                            (agent_is_alive, ":var_15"),
                            (player_get_kill_count, ":var_16", ":var_12"),
                            (val_add, ":var_16", 1),
                            (player_set_kill_count, ":var_12", ":var_16"),
                            (player_get_death_count, ":var_17", ":var_12"),
                            (val_sub, ":var_17", 1),
                            (player_set_death_count, ":var_12", ":var_17"),
                            (player_get_score, ":var_18", ":var_12"),
                            (val_add, ":var_18", 1),
                            (player_set_score, ":var_12", ":var_18"),
                            (try_for_range, ":var_13", 1, ":var_2"),
                                (player_is_active, ":var_13"),
                                (multiplayer_send_4_int_to_player, ":var_13", 86, ":var_12", ":var_18", ":var_16", ":var_17"),
                            (try_end),
                            (player_get_value_of_original_items, ":var_19", ":var_12"),
                            (player_get_gold, ":var_20", ":var_12"),
                            (val_add, ":var_20", ":var_19"),
                            (player_set_gold, ":var_12", ":var_20", 15000),
                        (try_end),
                        (player_set_troop_id, ":var_12", -1),
                        (player_set_team_no, ":var_12", ":var_9"),
                        (multiplayer_send_message_to_player, ":var_12", 79),
                    (try_end),
                (try_end),
                (call_script, "script_show_multiplayer_message", 2, 0),
                (multiplayer_get_my_player, ":var_21"),
                (get_max_players, ":var_2"),
                (try_for_range, ":var_13", 0, ":var_2"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_21", ":var_13"),
                    (multiplayer_send_int_to_player, ":var_13", 68, 2),
                (try_end),
                (assign, "$g_team_balance_next_round", 0),
            (try_end),
        (try_end),
        (assign, "$g_team_balance_next_round", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_set_slot, ":var_13", 0, 0),
            (player_get_agent_id, ":var_22", ":var_13"),
            (ge, ":var_22", 0),
            (agent_is_alive, ":var_22"),
            (player_save_picked_up_items_for_next_spawn, ":var_13"),
            (player_get_value_of_original_items, ":var_19", ":var_13"),
            (player_set_slot, ":var_13", 1, ":var_19"),
        (try_end),
        (assign, ":var_23", 500),
        (val_mul, ":var_23", "$g_multiplayer_round_earnings_multiplier"),
        (val_div, ":var_23", 100),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_get_gold, ":var_20", ":var_13"),
            (player_get_team_no, ":var_4", ":var_13"),
            (try_begin),
                (this_or_next|eq, ":var_4", 0),
                (eq, ":var_4", 1),
                (val_add, ":var_20", ":var_23"),
            (try_end),
            (try_begin),
                (player_get_slot, ":var_19", ":var_13", 1),
                (store_add, ":var_24", ":var_20", ":var_19"),
                (store_mul, ":var_25", "$g_multiplayer_initial_gold_multiplier", 10),
                (neg|ge, ":var_24", ":var_25"),
                (store_sub, ":var_26", ":var_25", ":var_24"),
                (val_add, ":var_20", ":var_26"),
            (try_end),
            (player_set_gold, ":var_13", ":var_20", 15000),
        (try_end),
        (assign, "$my_team_at_start_of_round", -1),
        (multiplayer_clear_scene),
        (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
        (try_begin),
            (eq, "$g_battle_death_mode_started", 2),
            (call_script, "script_move_death_mode_flags_down"),
        (try_end),
        (assign, "$g_battle_death_mode_started", 0),
        (assign, "$g_reduced_waiting_seconds", 0),
        (call_script, "script_multiplayer_close_gate_if_it_is_open"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_round_ended", 0),
        (assign, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1"),
        (assign, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2"),
        (store_mission_timer_a, "$g_round_start_time"),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (multiplayer_send_int_to_player, ":var_13", 78, -9999),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, ":var_0", "$g_multiplayer_num_bots_team_1"),
        (assign, ":var_1", "$g_multiplayer_num_bots_team_2"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (try_begin),
            (this_or_next|eq, ":var_0", 0),
            (eq, ":var_1", 0),
            (store_mission_timer_a, ":var_5"),
            (val_sub, ":var_5", "$g_round_start_time"),
            (neg|gt, ":var_5", 2),
            (store_mission_timer_a, "$g_round_start_time"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (try_begin),
                (player_slot_eq, ":var_1", 0, 0),
                (player_get_team_no, ":var_2", ":var_1"),
                (neg|ge, ":var_2", 2),
                (player_get_troop_id, ":var_3", ":var_1"),
                (ge, ":var_3", 0),
                (assign, ":var_4", 0),
                (assign, ":var_5", 0),
                (assign, ":var_6", 0),
                (try_begin),
                    (assign, ":var_7", 0),
                    (get_max_players, ":var_0"),
                    (try_for_range, ":var_8", 0, ":var_0"),
                        (player_is_active, ":var_8"),
                        (val_add, ":var_7", 1),
                        (player_get_team_no, ":var_9", ":var_8"),
                        (try_begin),
                            (eq, ":var_9", 0),
                            (val_add, ":var_5", 1),
                        (else_try),
                            (eq, ":var_9", 1),
                            (val_add, ":var_6", 1),
                        (try_end),
                    (try_end),
                    (store_mul, ":var_10", ":var_5", ":var_6"),
                    (store_mission_timer_a, ":var_11"),
                    (val_sub, ":var_11", "$g_round_start_time"),
                    (this_or_next|neg|ge, ":var_11", 30),
                    (this_or_next|neg|gt, ":var_7", 2),
                    (eq, ":var_10", 0),
                    (eq, "$g_round_ended", 0),
                    (assign, ":var_4", 1),
                (try_end),
                (eq, ":var_4", 1),
                (try_begin),
                    (eq, ":var_2", 0),
                    (assign, ":var_12", 0),
                (else_try),
                    (eq, ":var_2", 1),
                    (assign, ":var_12", 32),
                (try_end),
                (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
                (player_spawn_new_agent, ":var_1", ":var_12"),
                (player_set_slot, ":var_1", 0, 1),
            (else_try),
                (eq, "$g_multiplayer_player_respawn_as_bot", 1),
                (player_get_agent_id, ":var_13", ":var_1"),
                (ge, ":var_13", 0),
                (neg|agent_is_alive, ":var_13"),
                (agent_get_time_elapsed_since_removed, ":var_14", ":var_13"),
                (gt, ":var_14", "$g_multiplayer_respawn_period"),
                (player_get_team_no, ":var_2", ":var_1"),
                (assign, ":var_15", 0),
                (try_for_agents, ":var_16"),
                    (eq, ":var_15", 0),
                    (agent_is_alive, ":var_16"),
                    (agent_is_human, ":var_16"),
                    (agent_is_non_player, ":var_16"),
                    (agent_get_team, ":var_17", ":var_16"),
                    (eq, ":var_17", ":var_2"),
                    (assign, ":var_15", 1),
                (try_end),
                (try_begin),
                    (eq, ":var_15", 1),
                    (call_script, "script_find_most_suitable_bot_to_control", ":var_1"),
                    (player_control_agent, ":var_1", reg0),
                    (player_get_slot, ":var_18", ":var_1", 0),
                    (val_add, ":var_18", 1),
                    (player_set_slot, ":var_1", 0, ":var_18"),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (this_or_next|eq, "$g_multiplayer_game_type", 3),
                (eq, "$g_multiplayer_game_type", 6),
                (team_get_score, ":var_1", 0),
                (team_get_score, ":var_2", 1),
                (store_add, ":var_3", ":var_1", ":var_2"),
                (eq, ":var_3", 0),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (neg|ge, ":var_4", 20),
                (assign, ":var_5", 0),
            (else_try),
                (assign, ":var_5", 1),
            (try_end),
            (eq, ":var_5", 1),
            (store_random_in_range, ":var_6", 0, ":var_0"),
            (val_sub, ":var_6", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_6", 0),
                (assign, ":var_7", 0),
            (else_try),
                (assign, ":var_7", 1),
            (try_end),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (eq, "$g_multiplayer_game_type", 3),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (try_begin),
                    (neg|gt, ":var_4", 20),
                    (assign, ":var_8", 0),
                (else_try),
                    (assign, ":var_8", 1),
                (try_end),
            (else_try),
                (assign, ":var_8", 1),
            (try_end),
            (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":var_7", ":var_8"),
            (assign, ":var_9", reg0),
            (assign, ":var_10", reg1),
            (team_get_faction, ":var_11", ":var_7"),
            (assign, ":var_12", 0),
            (try_for_range, ":var_13", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_14", ":var_13"),
                (eq, ":var_14", ":var_11"),
                (val_add, ":var_12", 1),
            (try_end),
            (assign, ":var_15", 0),
            (get_max_players, ":var_16"),
            (try_for_range, ":var_17", 0, ":var_16"),
                (player_is_active, ":var_17"),
                (player_get_team_no, ":var_18", ":var_17"),
                (eq, ":var_7", ":var_18"),
                (assign, ":var_19", 0),
                (store_add, ":var_20", 35, ":var_12"),
                (try_for_range, ":var_21", 35, ":var_20"),
                    (player_slot_ge, ":var_17", ":var_21", 1),
                    (assign, ":var_19", 1),
                    (assign, ":var_20", 0),
                (try_end),
                (ge, ":var_19", 1),
                (val_add, ":var_15", 1),
            (try_end),
            (try_begin),
                (this_or_next|ge, ":var_10", 0),
                (eq, ":var_15", 0),
                (troop_get_inventory_slot, ":var_22", ":var_9", 8),
                (try_begin),
                    (ge, ":var_22", 0),
                    (assign, ":var_23", 1),
                (else_try),
                    (assign, ":var_23", 0),
                (try_end),
                (try_begin),
                    (eq, "$g_multiplayer_game_type", 6),
                    (store_mission_timer_a, ":var_4"),
                    (val_sub, ":var_4", "$g_round_start_time"),
                    (try_begin),
                        (neg|ge, ":var_4", 20),
                        (try_begin),
                            (eq, ":var_7", 0),
                            (call_script, "script_multiplayer_find_spawn_point", ":var_7", 1, ":var_23"),
                        (else_try),
                            (assign, reg0, 32),
                        (try_end),
                    (else_try),
                        (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                    (try_end),
                (else_try),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, reg0, 0),
                    (else_try),
                        (assign, reg0, 32),
                    (try_end),
                (else_try),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                (try_end),
                (store_current_scene, ":var_24"),
                (modify_visitors_at_site, ":var_24"),
                (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_7", ":var_10"),
                (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
                (try_begin),
                    (eq, ":var_7", 0),
                    (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
                (else_try),
                    (eq, ":var_7", 1),
                    (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_agents, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_group, ":var_1", ":var_0"),
            (try_begin),
                (neg|player_is_active, ":var_1"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (else_try),
                (player_get_team_no, ":var_2", ":var_1"),
                (agent_get_team, ":var_3", ":var_0"),
                (neg|eq, ":var_2", ":var_3"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_game_type", 2),
            (this_or_next|eq, "$g_multiplayer_game_type", 3),
            (eq, "$g_multiplayer_game_type", 6),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (store_mission_timer_a, ":var_1"),
                (val_sub, ":var_1", "$g_round_finish_time"),
                (store_sub, ":var_2", "$g_multiplayer_respawn_period", 1),
                (ge, ":var_1", ":var_2"),
                (store_mission_timer_a, ":var_3"),
                (try_begin),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (assign, ":var_4", 90),
                (else_try),
                    (assign, ":var_4", 120),
                (try_end),
                (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (gt, ":var_3", ":var_6"),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 1),
        (else_try),
            (neg|eq, "$g_multiplayer_game_type", 2),
            (neg|eq, "$g_multiplayer_game_type", 3),
            (neg|eq, "$g_multiplayer_game_type", 6),
            (neg|eq, "$g_multiplayer_game_type", 5),
            (store_mission_timer_a, ":var_3"),
            (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_3", ":var_5"),
            (assign, ":var_0", 1),
        (else_try),
            (team_get_score, ":var_7", 0),
            (team_get_score, ":var_8", 1),
            (try_begin),
                (neg|eq, "$g_multiplayer_game_type", 5),
                (try_begin),
                    (this_or_next|ge, ":var_7", "$g_multiplayer_game_max_points"),
                    (ge, ":var_8", "$g_multiplayer_game_max_points"),
                    (assign, ":var_0", 1),
                (try_end),
            (else_try),
                (assign, ":var_9", 0),
                (get_max_players, ":var_10"),
                (try_for_range, ":var_11", 0, ":var_10"),
                    (player_is_active, ":var_11"),
                    (player_get_agent_id, ":var_12", ":var_11"),
                    (ge, ":var_12", 0),
                    (neg|agent_is_non_player, ":var_12"),
                    (assign, ":var_9", 1),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_9", 1),
                (this_or_next|neg|gt, ":var_7", 0),
                (neg|gt, ":var_8", 0),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_round_time_counter"),
        (start_presentation, "prsnt_multiplayer_team_score_display"),
        (try_begin),
            (eq, "$g_battle_death_mode_started", 2),
            (start_presentation, "prsnt_multiplayer_flag_projection_display_bt"),
        (try_end),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"multiplayer_fd", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_0|mtef_no_auto_reset, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 3),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (assign, "$g_waiting_for_confirmation_to_terminate", 0),
        (assign, "$g_round_ended", 0),
        (assign, "$g_reduced_waiting_seconds", 0),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_round_start_time", 0),
        (try_end),
        (assign, "$my_team_at_start_of_round", -1),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_determine_team_flags", 0),
        (call_script, "script_determine_team_flags", 1),
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_destructible_target_1", "spr_catapult_destructible"),
        (assign, "$g_destructible_target_2", "spr_trebuchet_destructible"),
        (scene_prop_get_num_instances, ":var_0", "$g_destructible_target_1"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (scene_prop_get_instance, ":var_2", "$g_destructible_target_1", ":var_1"),
            (ge, ":var_2", 0),
            (scene_prop_set_team, ":var_2", 0),
        (try_end),
        (scene_prop_get_num_instances, ":var_3", "$g_destructible_target_2"),
        (try_for_range, ":var_4", 0, ":var_3"),
            (scene_prop_get_instance, ":var_5", "$g_destructible_target_2", ":var_4"),
            (ge, ":var_5", 0),
            (scene_prop_set_team, ":var_5", 0),
        (try_end),
        (try_begin),
            (scene_prop_get_num_instances, ":var_6", "spr_catapult_destructible"),
            (ge, ":var_6", 1),
            (scene_prop_get_instance, ":var_7", "spr_catapult_destructible", 0),
            (scene_prop_get_team, "$g_defender_team", ":var_7"),
        (else_try),
            (scene_prop_get_num_instances, ":var_8", "spr_trebuchet_destructible"),
            (ge, ":var_8", 1),
            (scene_prop_get_instance, ":var_9", "spr_trebuchet_destructible", 0),
            (scene_prop_get_team, "$g_defender_team", ":var_9"),
        (try_end),
        (assign, "$g_number_of_targets_destroyed", 0),
        (try_begin),
            (assign, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1"),
            (assign, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2"),
        (try_end),
        (start_presentation, "prsnt_multiplayer_destructible_targets_display"),
        (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
        (try_begin),
            (neg|ge, "$my_team_at_start_of_round", 0),
            (multiplayer_get_my_player, ":var_1"),
            (ge, ":var_1", 0),
            (player_get_agent_id, ":var_2", ":var_1"),
            (eq, ":var_2", ":var_0"),
            (ge, ":var_2", 0),
            (agent_get_team, "$my_team_at_start_of_round", ":var_2"),
        (try_end),
        (try_begin),
            (neg|multiplayer_is_server),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (assign, "$g_round_ended", 0),
                (call_script, "script_initialize_all_scene_prop_slots"),
                (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
                (call_script, "script_initialize_objects_clients"),
                (start_presentation, "prsnt_multiplayer_destructible_targets_display"),
                (try_begin),
                    (eq, "$g_team_balance_next_round", 1),
                    (assign, "$g_team_balance_next_round", 0),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (neg|ge, "$my_team_at_start_of_round", 0),
            (multiplayer_get_my_player, ":var_2"),
            (ge, ":var_2", 0),
            (player_get_agent_id, ":var_3", ":var_2"),
            (ge, ":var_3", 0),
            (agent_get_team, "$my_team_at_start_of_round", ":var_3"),
        (try_end),
        (try_begin),
            (agent_is_human, ":var_0"),
            (assign, ":var_4", 0),
            (assign, ":var_5", 0),
            (try_for_agents, ":var_6"),
                (agent_is_human, ":var_6"),
                (try_begin),
                    (agent_is_alive, ":var_6"),
                    (agent_get_team, ":var_7", ":var_6"),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (val_add, ":var_4", 1),
                    (else_try),
                        (eq, ":var_7", 1),
                        (val_add, ":var_5", 1),
                    (try_end),
                (try_end),
            (try_end),
            (try_begin),
                (eq, "$g_round_ended", 0),
                (try_begin),
                    (this_or_next|eq, ":var_4", 0),
                    (eq, ":var_5", 0),
                    (assign, "$g_winner_team", -1),
                    (assign, reg0, "$g_multiplayer_respawn_period"),
                    (try_begin),
                        (eq, ":var_4", 0),
                        (try_begin),
                            (neg|eq, ":var_5", 0),
                            (assign, "$g_winner_team", 1),
                        (try_end),
                        (try_begin),
                            (eq, "$g_winner_team", -1),
                        (else_try),
                            (eq, "$g_defender_team", 1),
                            (try_begin),
                                (neg|multiplayer_is_server),
                                (call_script, "script_calculate_number_of_targets_destroyed"),
                            (try_end),
                            (store_sub, ":var_8", 2, "$g_number_of_targets_destroyed"),
                            (call_script, "script_show_multiplayer_message", 16, ":var_8"),
                        (else_try),
                            (call_script, "script_show_multiplayer_message", 17, 0),
                        (try_end),
                    (else_try),
                        (try_begin),
                            (neg|eq, ":var_4", 0),
                            (assign, "$g_winner_team", 0),
                        (try_end),
                        (try_begin),
                            (eq, "$g_winner_team", -1),
                        (else_try),
                            (eq, "$g_defender_team", 0),
                            (try_begin),
                                (neg|multiplayer_is_server),
                                (call_script, "script_calculate_number_of_targets_destroyed"),
                            (try_end),
                            (store_sub, ":var_8", 2, "$g_number_of_targets_destroyed"),
                            (call_script, "script_show_multiplayer_message", 16, ":var_8"),
                        (else_try),
                            (call_script, "script_show_multiplayer_message", 17, 0),
                        (try_end),
                    (try_end),
                    (store_mission_timer_a, "$g_round_finish_time"),
                    (assign, "$g_round_ended", 1),
                    (try_begin),
                        (multiplayer_is_server),
                        (ge, "$g_winner_team", 0),
                        (neg|ge, "$g_winner_team", 2),
                        (neg|eq, "$g_winner_team", -1),
                        (team_get_score, ":var_9", "$g_winner_team"),
                        (store_sub, ":var_10", 2, "$g_number_of_targets_destroyed"),
                        (val_add, ":var_9", ":var_10"),
                        (call_script, "script_team_set_score", "$g_winner_team", ":var_9"),
                        (get_max_players, ":var_11"),
                        (try_for_range, ":var_12", 1, ":var_11"),
                            (player_is_active, ":var_12"),
                            (multiplayer_send_2_int_to_player, ":var_12", 72, "$g_winner_team", ":var_9"),
                        (try_end),
                    (try_end),
                    (try_begin),
                        (neg|eq, "$g_defender_team", "$g_winner_team"),
                        (neg|eq, "$g_winner_team", -1),
                        (assign, "$g_number_of_targets_destroyed", 2),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (multiplayer_is_server),
            (agent_is_human, ":var_0"),
            (neg|agent_is_non_player, ":var_0"),
            (ge, ":var_0", 0),
            (agent_get_player_id, ":var_13", ":var_0"),
            (ge, ":var_13", 0),
            (set_fixed_point_multiplier, 100),
            (agent_get_player_id, ":var_13", ":var_0"),
            (agent_get_position, pos0, ":var_0"),
            (position_get_x, ":var_14", pos0),
            (position_get_y, ":var_15", pos0),
            (position_get_z, ":var_16", pos0),
            (player_set_slot, ":var_13", 29, ":var_14"),
            (player_set_slot, ":var_13", 30, ":var_15"),
            (player_set_slot, ":var_13", 31, ":var_16"),
        (try_end),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_number_of_targets_destroyed", 2),
    ],
    [
        (store_mission_timer_a, "$g_round_finish_time"),
        (assign, "$g_round_ended", 1),
        (multiplayer_get_my_player, ":var_0"),
        (call_script, "script_draw_this_round", -9),
        (get_max_players, ":var_1"),
        (try_for_range, ":var_2", 1, ":var_1"),
            (player_is_active, ":var_2"),
            (neg|eq, ":var_2", ":var_0"),
            (multiplayer_send_int_to_player, ":var_2", 69, -9),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_sub, ":var_1", ":var_0", "$g_round_start_time"),
        (ge, ":var_1", "$g_multiplayer_round_max_seconds"),
    ],
    [
        (store_mission_timer_a, "$g_round_finish_time"),
        (assign, "$g_round_ended", 1),
        (assign, "$g_winner_team", -9),
        (multiplayer_get_my_player, ":var_0"),
        (store_sub, ":var_1", 2, "$g_number_of_targets_destroyed"),
        (call_script, "script_show_multiplayer_message", 16, ":var_1"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 1, ":var_2"),
            (player_is_active, ":var_3"),
            (multiplayer_send_2_int_to_player, ":var_3", 68, 16, ":var_1"),
        (try_end),
        (call_script, "script_draw_this_round", "$g_winner_team"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 1, ":var_2"),
            (player_is_active, ":var_3"),
            (neg|eq, ":var_3", ":var_0"),
            (multiplayer_send_int_to_player, ":var_3", 69, "$g_winner_team"),
        (try_end),
        (try_begin),
            (multiplayer_is_server),
            (assign, "$g_winner_team", "$g_defender_team"),
            (team_get_score, ":var_4", "$g_winner_team"),
            (store_sub, ":var_5", 2, "$g_number_of_targets_destroyed"),
            (val_add, ":var_4", ":var_5"),
            (call_script, "script_team_set_score", "$g_winner_team", ":var_4"),
            (try_for_range, ":var_3", 1, ":var_2"),
                (player_is_active, ":var_3"),
                (multiplayer_send_2_int_to_player, ":var_3", 72, "$g_winner_team", ":var_4"),
            (try_end),
        (try_end),
    ]),

    (10.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
    ],
    [
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_5", ":var_0", ":var_1"),
        (assign, ":var_6", 0),
        (try_begin),
            (try_begin),
                (store_mul, ":var_7", "$g_multiplayer_auto_team_balance_limit", -1),
                (neg|gt, ":var_5", ":var_7"),
                (store_div, ":var_6", ":var_5", -2),
            (else_try),
                (ge, ":var_5", "$g_multiplayer_auto_team_balance_limit"),
                (store_div, ":var_6", ":var_5", 2),
            (try_end),
        (try_end),
        (try_begin),
            (gt, ":var_6", 0),
            (try_begin),
                (eq, "$g_team_balance_next_round", 0),
                (assign, "$g_team_balance_next_round", 1),
                (call_script, "script_show_multiplayer_message", 3, 0),
                (get_max_players, ":var_2"),
                (try_for_range, ":var_8", 1, ":var_2"),
                    (player_is_active, ":var_8"),
                    (multiplayer_send_int_to_player, ":var_8", 68, 3),
                (try_end),
                (call_script, "script_warn_player_about_auto_team_balance"),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 0),
        (eq, "$g_battle_death_mode_started", 2),
    ],
    [
        (set_fixed_point_multiplier, 100),
        (scene_prop_get_instance, ":var_0", "spr_headquarters_pole_code_only", 0),
        (scene_prop_get_instance, ":var_1", "spr_headquarters_pole_code_only", 1),
        (scene_prop_get_instance, ":var_2", "$team_1_flag_scene_prop", 0),
        (scene_prop_get_instance, ":var_3", "$team_2_flag_scene_prop", 0),
        (prop_instance_get_position, pos1, ":var_0"),
        (prop_instance_get_position, pos2, ":var_1"),
        (prop_instance_get_position, pos3, ":var_2"),
        (prop_instance_get_position, pos4, ":var_3"),
        (copy_position, pos7, pos1),
        (position_move_z, pos7, 100),
        (copy_position, pos8, pos2),
        (position_move_z, pos8, 100),
        (get_distance_between_positions, ":var_4", pos1, pos3),
        (get_distance_between_positions, ":var_5", pos2, pos4),
        (assign, ":var_6", 0),
        (assign, ":var_7", 0),
        (get_max_players, ":var_8"),
        (try_for_range, ":var_9", 0, ":var_8"),
            (player_is_active, ":var_9"),
            (player_get_agent_id, ":var_10", ":var_9"),
            (ge, ":var_10", 0),
            (agent_is_human, ":var_10"),
            (agent_is_alive, ":var_10"),
            (agent_get_team, ":var_11", ":var_10"),
            (agent_get_position, pos0, ":var_10"),
            (agent_get_horse, ":var_12", ":var_10"),
            (eq, ":var_12", -1),
            (try_begin),
                (eq, ":var_11", 0),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos1),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (eq, ":var_6", 0),
                        (assign, ":var_6", 1),
                    (else_try),
                        (eq, ":var_6", -1),
                        (assign, ":var_6", -2),
                    (try_end),
                (try_end),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos2),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, ":var_7", -1),
                    (else_try),
                        (eq, ":var_7", 1),
                        (assign, ":var_7", -2),
                    (try_end),
                (try_end),
            (else_try),
                (eq, ":var_11", 1),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos2),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, ":var_7", 1),
                    (else_try),
                        (assign, ":var_7", -2),
                    (try_end),
                (try_end),
                (try_begin),
                    (get_sq_distance_between_positions, ":var_13", pos0, pos1),
                    (neg|ge, ":var_13", 1600),
                    (try_begin),
                        (eq, ":var_6", 0),
                        (assign, ":var_6", -1),
                    (else_try),
                        (eq, ":var_6", 1),
                        (assign, ":var_6", -2),
                    (try_end),
                (try_end),
            (try_end),
        (try_end),
        (try_begin),
            (ge, ":var_4", 800),
            (assign, "$g_winner_team", 0),
            (get_max_players, ":var_8"),
            (call_script, "script_draw_this_round", "$g_winner_team"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_int_to_player, ":var_9", 69, "$g_winner_team"),
            (try_end),
            (team_get_score, ":var_14", 0),
            (call_script, "script_team_set_score", 0, ":var_14"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_2_int_to_player, ":var_9", 72, 0, ":var_14"),
            (try_end),
            (store_mission_timer_a, "$g_round_finish_time"),
            (assign, "$g_round_ended", 1),
        (else_try),
            (ge, ":var_5", 800),
            (assign, "$g_winner_team", 1),
            (get_max_players, ":var_8"),
            (call_script, "script_draw_this_round", "$g_winner_team"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_int_to_player, ":var_9", 69, "$g_winner_team"),
            (try_end),
            (team_get_score, ":var_15", 1),
            (call_script, "script_team_set_score", 1, ":var_15"),
            (try_for_range, ":var_9", 1, ":var_8"),
                (player_is_active, ":var_9"),
                (multiplayer_send_2_int_to_player, ":var_9", 72, 1, ":var_15"),
            (try_end),
            (call_script, "script_show_multiplayer_message", 12, 0),
            (call_script, "script_check_achievement_last_man_standing", "$g_winner_team"),
            (store_mission_timer_a, "$g_round_finish_time"),
            (assign, "$g_round_ended", 1),
        (try_end),
        (try_begin),
            (eq, "$g_round_ended", 0),
            (position_get_z, ":var_16", pos3),
            (prop_instance_is_animating, ":var_17", ":var_2"),
            (try_begin),
                (eq, ":var_6", -2),
                (eq, ":var_17", 1),
                (prop_instance_stop_animating, ":var_2"),
            (else_try),
                (this_or_next|eq, ":var_6", 0),
                (eq, ":var_6", -1),
                (prop_instance_get_animation_target_position, 9, ":var_2"),
                (position_get_z, ":var_18", pos9),
                (this_or_next|eq, ":var_17", 0),
                (gt, ":var_18", ":var_16"),
                (get_distance_between_positions, ":var_19", pos3, pos7),
                (gt, ":var_19", 0),
                (val_mul, ":var_19", 16),
                (prop_instance_animate_to_position, ":var_2", 7, ":var_19"),
            (else_try),
                (eq, ":var_6", 1),
                (prop_instance_get_animation_target_position, 9, ":var_2"),
                (position_get_z, ":var_18", pos9),
                (this_or_next|eq, ":var_17", 0),
                (neg|ge, ":var_18", ":var_16"),
                (copy_position, pos5, pos1),
                (position_move_z, pos5, 800),
                (get_distance_between_positions, ":var_19", pos3, pos5),
                (gt, ":var_19", 0),
                (val_mul, ":var_19", 8),
                (prop_instance_animate_to_position, ":var_2", 5, ":var_19"),
            (try_end),
            (position_get_z, ":var_20", pos4),
            (prop_instance_is_animating, ":var_17", ":var_3"),
            (try_begin),
                (eq, ":var_7", -2),
                (eq, ":var_17", 1),
                (prop_instance_stop_animating, ":var_3"),
            (else_try),
                (this_or_next|eq, ":var_7", 0),
                (eq, ":var_7", -1),
                (prop_instance_get_animation_target_position, 9, ":var_3"),
                (position_get_z, ":var_21", pos9),
                (this_or_next|eq, ":var_17", 0),
                (gt, ":var_21", ":var_20"),
                (get_distance_between_positions, ":var_22", pos4, pos8),
                (gt, ":var_22", 0),
                (val_mul, ":var_22", 16),
                (prop_instance_animate_to_position, ":var_3", 8, ":var_22"),
            (else_try),
                (eq, ":var_7", 1),
                (prop_instance_get_animation_target_position, 9, ":var_3"),
                (position_get_z, ":var_21", pos9),
                (this_or_next|eq, ":var_17", 0),
                (neg|ge, ":var_21", ":var_20"),
                (copy_position, pos6, pos2),
                (position_move_z, pos6, 800),
                (get_distance_between_positions, ":var_22", pos4, pos6),
                (gt, ":var_22", 0),
                (val_mul, ":var_22", 8),
                (prop_instance_animate_to_position, ":var_3", 6, ":var_22"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 3.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_round_ended", 1),
        (store_mission_timer_a, ":var_0"),
        (val_sub, ":var_0", "$g_round_finish_time"),
        (ge, ":var_0", "$g_multiplayer_respawn_period"),
    ],
    [
        (assign, ":var_0", 0),
        (assign, ":var_1", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (store_sub, ":var_5", ":var_0", ":var_1"),
        (assign, ":var_6", 0),
        (try_begin),
            (try_begin),
                (store_mul, ":var_7", "$g_multiplayer_auto_team_balance_limit", -1),
                (neg|gt, ":var_5", ":var_7"),
                (store_div, ":var_6", ":var_5", -2),
                (assign, ":var_8", 1),
                (assign, ":var_9", 0),
            (else_try),
                (ge, ":var_5", "$g_multiplayer_auto_team_balance_limit"),
                (store_div, ":var_6", ":var_5", 2),
                (assign, ":var_8", 0),
                (assign, ":var_9", 1),
            (try_end),
        (try_end),
        (try_begin),
            (gt, ":var_6", 0),
            (try_begin),
                (try_for_range, ":var_10", 0, ":var_6"),
                    (assign, ":var_11", 0),
                    (assign, ":var_12", -1),
                    (get_max_players, ":var_2"),
                    (try_for_range, ":var_13", 0, ":var_2"),
                        (player_is_active, ":var_13"),
                        (player_get_team_no, ":var_4", ":var_13"),
                        (eq, ":var_4", ":var_8"),
                        (player_get_slot, ":var_14", ":var_13", 21),
                        (try_begin),
                            (gt, ":var_14", ":var_11"),
                            (assign, ":var_11", ":var_14"),
                            (assign, ":var_12", ":var_13"),
                        (try_end),
                    (try_end),
                    (try_begin),
                        (ge, ":var_12", 0),
                        (try_begin),
                            (player_get_agent_id, ":var_15", ":var_12"),
                            (ge, ":var_15", 0),
                            (agent_is_alive, ":var_15"),
                            (player_get_kill_count, ":var_16", ":var_12"),
                            (val_add, ":var_16", 1),
                            (player_set_kill_count, ":var_12", ":var_16"),
                            (player_get_death_count, ":var_17", ":var_12"),
                            (val_sub, ":var_17", 1),
                            (player_set_death_count, ":var_12", ":var_17"),
                            (player_get_score, ":var_18", ":var_12"),
                            (val_add, ":var_18", 1),
                            (player_set_score, ":var_12", ":var_18"),
                            (try_for_range, ":var_13", 1, ":var_2"),
                                (player_is_active, ":var_13"),
                                (multiplayer_send_4_int_to_player, ":var_13", 86, ":var_12", ":var_18", ":var_16", ":var_17"),
                            (try_end),
                            (player_get_value_of_original_items, ":var_19", ":var_12"),
                            (player_get_gold, ":var_20", ":var_12"),
                            (val_add, ":var_20", ":var_19"),
                            (player_set_gold, ":var_12", ":var_20", 15000),
                        (try_end),
                        (player_set_troop_id, ":var_12", -1),
                        (player_set_team_no, ":var_12", ":var_9"),
                        (multiplayer_send_message_to_player, ":var_12", 79),
                    (try_end),
                (try_end),
                (call_script, "script_show_multiplayer_message", 2, 0),
                (multiplayer_get_my_player, ":var_21"),
                (get_max_players, ":var_2"),
                (try_for_range, ":var_13", 0, ":var_2"),
                    (player_is_active, ":var_13"),
                    (neg|eq, ":var_21", ":var_13"),
                    (multiplayer_send_int_to_player, ":var_13", 68, 2),
                (try_end),
                (assign, "$g_team_balance_next_round", 0),
            (try_end),
        (try_end),
        (assign, "$g_team_balance_next_round", 0),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_set_slot, ":var_13", 0, 0),
            (player_get_agent_id, ":var_22", ":var_13"),
            (ge, ":var_22", 0),
            (agent_is_alive, ":var_22"),
            (player_save_picked_up_items_for_next_spawn, ":var_13"),
            (player_get_value_of_original_items, ":var_19", ":var_13"),
            (player_set_slot, ":var_13", 1, ":var_19"),
        (try_end),
        (assign, ":var_23", 500),
        (val_mul, ":var_23", "$g_multiplayer_round_earnings_multiplier"),
        (val_div, ":var_23", 100),
        (store_sub, ":var_24", 2, "$g_number_of_targets_destroyed"),
        (store_mul, ":var_25", ":var_24", 100),
        (store_mul, ":var_26", "$g_number_of_targets_destroyed", 100),
        (val_add, ":var_25", 100),
        (val_sub, ":var_26", 100),
        (get_max_players, ":var_2"),
        (val_mul, ":var_25", "$g_multiplayer_round_earnings_multiplier"),
        (val_div, ":var_25", 100),
        (val_mul, ":var_26", "$g_multiplayer_round_earnings_multiplier"),
        (val_div, ":var_26", 100),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (player_get_gold, ":var_20", ":var_13"),
            (player_get_team_no, ":var_4", ":var_13"),
            (val_add, ":var_20", ":var_23"),
            (try_begin),
                (eq, ":var_4", "$g_defender_team"),
                (val_add, ":var_20", ":var_25"),
            (else_try),
                (val_add, ":var_20", ":var_26"),
            (try_end),
            (try_begin),
                (player_get_slot, ":var_19", ":var_13", 1),
                (store_add, ":var_27", ":var_20", ":var_19"),
                (store_mul, ":var_28", "$g_multiplayer_initial_gold_multiplier", 10),
                (neg|ge, ":var_27", ":var_28"),
                (store_sub, ":var_29", ":var_28", ":var_27"),
                (val_add, ":var_20", ":var_29"),
            (try_end),
            (player_set_gold, ":var_13", ":var_20", 15000),
        (try_end),
        (assign, "$my_team_at_start_of_round", -1),
        (multiplayer_clear_scene),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 1, ":var_2"),
            (player_is_active, ":var_13"),
            (player_set_slot, ":var_13", 32, 0),
            (player_set_slot, ":var_13", 33, 0),
        (try_end),
        (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),
        (call_script, "script_multiplayer_close_gate_if_it_is_open"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_round_ended", 0),
        (assign, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1"),
        (assign, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2"),
        (start_presentation, "prsnt_multiplayer_destructible_targets_display"),
        (call_script, "script_initialize_objects"),
        (store_mission_timer_a, "$g_round_start_time"),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_13", 0, ":var_2"),
            (player_is_active, ":var_13"),
            (multiplayer_send_int_to_player, ":var_13", 78, -9999),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, ":var_0", "$g_multiplayer_num_bots_team_1"),
        (assign, ":var_1", "$g_multiplayer_num_bots_team_2"),
        (get_max_players, ":var_2"),
        (try_for_range, ":var_3", 0, ":var_2"),
            (player_is_active, ":var_3"),
            (player_get_team_no, ":var_4", ":var_3"),
            (try_begin),
                (eq, ":var_4", 0),
                (val_add, ":var_0", 1),
            (else_try),
                (eq, ":var_4", 1),
                (val_add, ":var_1", 1),
            (try_end),
        (try_end),
        (try_begin),
            (this_or_next|eq, ":var_0", 0),
            (eq, ":var_1", 0),
            (store_mission_timer_a, ":var_5"),
            (val_sub, ":var_5", "$g_round_start_time"),
            (neg|gt, ":var_5", 2),
            (store_mission_timer_a, "$g_round_start_time"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (try_begin),
                (player_slot_eq, ":var_1", 0, 0),
                (player_get_team_no, ":var_2", ":var_1"),
                (neg|ge, ":var_2", 2),
                (player_get_troop_id, ":var_3", ":var_1"),
                (ge, ":var_3", 0),
                (assign, ":var_4", 0),
                (assign, ":var_5", 0),
                (assign, ":var_6", 0),
                (try_begin),
                    (assign, ":var_7", 0),
                    (get_max_players, ":var_0"),
                    (try_for_range, ":var_8", 0, ":var_0"),
                        (player_is_active, ":var_8"),
                        (val_add, ":var_7", 1),
                        (player_get_team_no, ":var_9", ":var_8"),
                        (try_begin),
                            (eq, ":var_9", 0),
                            (val_add, ":var_5", 1),
                        (else_try),
                            (eq, ":var_9", 1),
                            (val_add, ":var_6", 1),
                        (try_end),
                    (try_end),
                    (store_mul, ":var_10", ":var_5", ":var_6"),
                    (store_mission_timer_a, ":var_11"),
                    (val_sub, ":var_11", "$g_round_start_time"),
                    (this_or_next|neg|ge, ":var_11", 30),
                    (this_or_next|neg|gt, ":var_7", 2),
                    (eq, ":var_10", 0),
                    (eq, "$g_round_ended", 0),
                    (assign, ":var_4", 1),
                (try_end),
                (eq, ":var_4", 1),
                (try_begin),
                    (eq, ":var_2", 0),
                    (assign, ":var_12", 0),
                (else_try),
                    (eq, ":var_2", 1),
                    (assign, ":var_12", 32),
                (try_end),
                (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
                (player_spawn_new_agent, ":var_1", ":var_12"),
                (player_set_slot, ":var_1", 0, 1),
            (else_try),
                (eq, "$g_multiplayer_player_respawn_as_bot", 1),
                (player_get_agent_id, ":var_13", ":var_1"),
                (ge, ":var_13", 0),
                (neg|agent_is_alive, ":var_13"),
                (agent_get_time_elapsed_since_removed, ":var_14", ":var_13"),
                (gt, ":var_14", "$g_multiplayer_respawn_period"),
                (player_get_team_no, ":var_2", ":var_1"),
                (assign, ":var_15", 0),
                (try_for_agents, ":var_16"),
                    (eq, ":var_15", 0),
                    (agent_is_alive, ":var_16"),
                    (agent_is_human, ":var_16"),
                    (agent_is_non_player, ":var_16"),
                    (agent_get_team, ":var_17", ":var_16"),
                    (eq, ":var_17", ":var_2"),
                    (assign, ":var_15", 1),
                (try_end),
                (try_begin),
                    (eq, ":var_15", 1),
                    (call_script, "script_find_most_suitable_bot_to_control", ":var_1"),
                    (player_control_agent, ":var_1", reg0),
                    (player_get_slot, ":var_18", ":var_1", 0),
                    (val_add, ":var_18", 1),
                    (player_set_slot, ":var_1", 0, ":var_18"),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (this_or_next|eq, "$g_multiplayer_game_type", 3),
                (eq, "$g_multiplayer_game_type", 6),
                (team_get_score, ":var_1", 0),
                (team_get_score, ":var_2", 1),
                (store_add, ":var_3", ":var_1", ":var_2"),
                (eq, ":var_3", 0),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (neg|ge, ":var_4", 20),
                (assign, ":var_5", 0),
            (else_try),
                (assign, ":var_5", 1),
            (try_end),
            (eq, ":var_5", 1),
            (store_random_in_range, ":var_6", 0, ":var_0"),
            (val_sub, ":var_6", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_6", 0),
                (assign, ":var_7", 0),
            (else_try),
                (assign, ":var_7", 1),
            (try_end),
            (try_begin),
                (this_or_next|eq, "$g_multiplayer_game_type", 2),
                (eq, "$g_multiplayer_game_type", 3),
                (store_mission_timer_a, ":var_4"),
                (val_sub, ":var_4", "$g_round_start_time"),
                (try_begin),
                    (neg|gt, ":var_4", 20),
                    (assign, ":var_8", 0),
                (else_try),
                    (assign, ":var_8", 1),
                (try_end),
            (else_try),
                (assign, ":var_8", 1),
            (try_end),
            (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":var_7", ":var_8"),
            (assign, ":var_9", reg0),
            (assign, ":var_10", reg1),
            (team_get_faction, ":var_11", ":var_7"),
            (assign, ":var_12", 0),
            (try_for_range, ":var_13", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_14", ":var_13"),
                (eq, ":var_14", ":var_11"),
                (val_add, ":var_12", 1),
            (try_end),
            (assign, ":var_15", 0),
            (get_max_players, ":var_16"),
            (try_for_range, ":var_17", 0, ":var_16"),
                (player_is_active, ":var_17"),
                (player_get_team_no, ":var_18", ":var_17"),
                (eq, ":var_7", ":var_18"),
                (assign, ":var_19", 0),
                (store_add, ":var_20", 35, ":var_12"),
                (try_for_range, ":var_21", 35, ":var_20"),
                    (player_slot_ge, ":var_17", ":var_21", 1),
                    (assign, ":var_19", 1),
                    (assign, ":var_20", 0),
                (try_end),
                (ge, ":var_19", 1),
                (val_add, ":var_15", 1),
            (try_end),
            (try_begin),
                (this_or_next|ge, ":var_10", 0),
                (eq, ":var_15", 0),
                (troop_get_inventory_slot, ":var_22", ":var_9", 8),
                (try_begin),
                    (ge, ":var_22", 0),
                    (assign, ":var_23", 1),
                (else_try),
                    (assign, ":var_23", 0),
                (try_end),
                (try_begin),
                    (eq, "$g_multiplayer_game_type", 6),
                    (store_mission_timer_a, ":var_4"),
                    (val_sub, ":var_4", "$g_round_start_time"),
                    (try_begin),
                        (neg|ge, ":var_4", 20),
                        (try_begin),
                            (eq, ":var_7", 0),
                            (call_script, "script_multiplayer_find_spawn_point", ":var_7", 1, ":var_23"),
                        (else_try),
                            (assign, reg0, 32),
                        (try_end),
                    (else_try),
                        (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                    (try_end),
                (else_try),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (try_begin),
                        (eq, ":var_7", 0),
                        (assign, reg0, 0),
                    (else_try),
                        (assign, reg0, 32),
                    (try_end),
                (else_try),
                    (call_script, "script_multiplayer_find_spawn_point", ":var_7", 0, ":var_23"),
                (try_end),
                (store_current_scene, ":var_24"),
                (modify_visitors_at_site, ":var_24"),
                (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_7", ":var_10"),
                (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
                (try_begin),
                    (eq, ":var_7", 0),
                    (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
                (else_try),
                    (eq, ":var_7", 1),
                    (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (try_for_agents, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_group, ":var_1", ":var_0"),
            (try_begin),
                (neg|player_is_active, ":var_1"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (else_try),
                (player_get_team_no, ":var_2", ":var_1"),
                (agent_get_team, ":var_3", ":var_0"),
                (neg|eq, ":var_2", ":var_3"),
                (call_script, "script_multiplayer_change_leader_of_bot", ":var_0"),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_game_type", 2),
            (this_or_next|eq, "$g_multiplayer_game_type", 3),
            (eq, "$g_multiplayer_game_type", 6),
            (try_begin),
                (eq, "$g_round_ended", 1),
                (store_mission_timer_a, ":var_1"),
                (val_sub, ":var_1", "$g_round_finish_time"),
                (store_sub, ":var_2", "$g_multiplayer_respawn_period", 1),
                (ge, ":var_1", ":var_2"),
                (store_mission_timer_a, ":var_3"),
                (try_begin),
                    (this_or_next|eq, "$g_multiplayer_game_type", 2),
                    (eq, "$g_multiplayer_game_type", 3),
                    (assign, ":var_4", 90),
                (else_try),
                    (assign, ":var_4", 120),
                (try_end),
                (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
                (store_sub, ":var_6", ":var_5", ":var_4"),
                (gt, ":var_3", ":var_6"),
                (assign, ":var_0", 1),
            (try_end),
            (eq, ":var_0", 1),
        (else_try),
            (neg|eq, "$g_multiplayer_game_type", 2),
            (neg|eq, "$g_multiplayer_game_type", 3),
            (neg|eq, "$g_multiplayer_game_type", 6),
            (neg|eq, "$g_multiplayer_game_type", 5),
            (store_mission_timer_a, ":var_3"),
            (store_mul, ":var_5", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_3", ":var_5"),
            (assign, ":var_0", 1),
        (else_try),
            (team_get_score, ":var_7", 0),
            (team_get_score, ":var_8", 1),
            (try_begin),
                (neg|eq, "$g_multiplayer_game_type", 5),
                (try_begin),
                    (this_or_next|ge, ":var_7", "$g_multiplayer_game_max_points"),
                    (ge, ":var_8", "$g_multiplayer_game_max_points"),
                    (assign, ":var_0", 1),
                (try_end),
            (else_try),
                (assign, ":var_9", 0),
                (get_max_players, ":var_10"),
                (try_for_range, ":var_11", 0, ":var_10"),
                    (player_is_active, ":var_11"),
                    (player_get_agent_id, ":var_12", ":var_11"),
                    (ge, ":var_12", 0),
                    (neg|agent_is_non_player, ":var_12"),
                    (assign, ":var_9", 1),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_9", 1),
                (this_or_next|neg|gt, ":var_7", 0),
                (neg|gt, ":var_8", 0),
                (assign, ":var_0", 1),
            (try_end),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_battle_window_opened, 0.000000, 0.000000, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_round_time_counter"),
        (start_presentation, "prsnt_multiplayer_team_score_display"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),


],),

(
"bandit_lair", 2, 8, 
"Ambushing_a_bandit_lair",
[(0, mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 7, []),
(1, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(2, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(3, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(4, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(5, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(6, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(7, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(8, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(9, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(10, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (assign, "$relative_of_merchant_is_found", 0),
        (try_begin),
            (agent_is_human, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_team, ":var_1", ":var_0"),
            (eq, ":var_1", 1),
            (agent_get_position, pos4, ":var_0"),
            (agent_set_scripted_destination, ":var_0", pos4, 1),
        (try_end),
        (try_begin),
            (agent_get_troop_id, ":var_2", ":var_0"),
            (is_between, ":var_2", "trp_relative_of_merchant_sarleon", "trp_relative_of_merchants_end"),
            (agent_set_team, ":var_0", 7),
            (team_set_relation, 0, 7, 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (party_get_template_id, ":var_0", "$g_encountered_party"),
        (eq, ":var_0", "pt_looter_lair"),
        (check_quest_active, "qst_save_relative_of_merchant"),
        (eq, "$relative_of_merchant_is_found", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos0, ":var_0"),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (is_between, ":var_2", "trp_relative_of_merchant_sarleon", "trp_relative_of_merchants_end"),
            (agent_set_scripted_destination, ":var_1", pos0),
            (agent_get_position, pos1, ":var_1"),
            (get_distance_between_positions, ":var_3", pos0, pos1),
            (neg|gt, ":var_3", 200),
            (start_mission_conversation, ":var_2"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (neg|main_hero_fallen),
        (num_active_teams_le, 1),
        (party_get_template_id, ":var_0", "$g_encountered_party"),
        (eq, ":var_0", "pt_treasure_lair"),
        (party_set_slot, "$g_encountered_party", slot_party_ai_substate, 2),
        (finish_mission),
    ],
    [
    ]),

    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$defender_reinforcement_stage", 0),
        (assign, "$bandits_spawned_extra", 0),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_get_team, ":var_1", ":var_0"),
            (eq, ":var_1", 1),
            (agent_is_in_special_mode, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_position, pos0, ":var_0"),
            (try_for_agents, ":var_2"),
                (agent_is_alive, ":var_2"),
                (agent_get_team, ":var_3", ":var_2"),
                (eq, ":var_3", 0),
                (agent_is_human, ":var_2"),
                (store_agent_hit_points, ":var_4", ":var_0"),
                (assign, ":var_5", 0),
                (try_begin),
                    (neg|ge, ":var_4", 100),
                    (try_for_agents, ":var_6"),
                        (agent_is_alive, ":var_6"),
                        (agent_get_team, ":var_7", ":var_6"),
                        (eq, ":var_7", 1),
                        (neg|eq, ":var_0", ":var_6"),
                        (agent_is_in_special_mode, ":var_6"),
                        (agent_is_human, ":var_6"),
                        (agent_get_position, pos1, ":var_0"),
                        (agent_get_position, pos2, ":var_6"),
                        (get_distance_between_positions, ":var_8", pos1, pos2),
                        (neg|gt, ":var_8", 1000),
                        (agent_clear_scripted_mode, ":var_6"),
                    (try_end),
                    (assign, ":var_5", 1),
                (else_try),
                    (agent_get_position, pos1, ":var_0"),
                    (agent_get_position, pos2, ":var_2"),
                    (get_distance_between_positions, ":var_8", pos1, pos2),
                    (neg|gt, ":var_8", 4000),
                    (try_for_agents, ":var_6"),
                        (agent_is_alive, ":var_6"),
                        (agent_get_team, ":var_7", ":var_6"),
                        (eq, ":var_7", 1),
                        (neg|eq, ":var_0", ":var_6"),
                        (agent_is_in_special_mode, ":var_6"),
                        (agent_is_human, ":var_6"),
                        (agent_get_position, pos1, ":var_0"),
                        (agent_get_position, pos2, ":var_6"),
                        (get_distance_between_positions, ":var_8", pos1, pos2),
                        (neg|gt, ":var_8", 1000),
                        (agent_clear_scripted_mode, ":var_6"),
                    (try_end),
                    (assign, ":var_5", 1),
                (try_end),
                (eq, ":var_5", 1),
                (agent_clear_scripted_mode, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (30.000000, 0.000000, 0.000000, 
    [
        (neg|gt, "$defender_reinforcement_stage", 1),
    ],
    [
        (store_character_level, ":var_0", "trp_player"),
        (store_add, ":var_1", 5, ":var_0"),
        (val_div, ":var_1", 3),
        (neg|ge, "$bandits_spawned_extra", ":var_1"),
        (val_add, "$bandits_spawned_extra", 1),
        (party_get_template_id, ":var_2", "$g_encountered_party"),
        (store_random_in_range, ":var_3", 0, 2),
        (try_begin),
            (eq, ":var_2", "pt_sea_raider_lair"),
            (assign, ":var_4", "trp_sea_raider"),
            (assign, ":var_5", "trp_vanskerry_lair_leader"),
        (else_try),
            (eq, ":var_2", "pt_forest_bandit_lair"),
            (assign, ":var_4", "trp_forest_bandit"),
            (assign, ":var_5", "trp_heretic_lair_leader"),
        (else_try),
            (eq, ":var_2", "pt_mountain_bandit_lair"),
            (assign, ":var_4", "trp_mountain_bandit"),
            (assign, ":var_5", "trp_myst_lair_leader"),
        (else_try),
            (eq, ":var_2", "pt_snake_bandit_lair"),
            (assign, ":var_4", "trp_snake_armsman"),
            (assign, ":var_5", "trp_snake_lair_leader"),
        (else_try),
            (eq, ":var_2", "pt_steppe_bandit_lair"),
            (assign, ":var_4", "trp_steppe_bandit"),
            (assign, ":var_5", "trp_singal_lair_leader"),
        (else_try),
            (eq, ":var_2", "pt_treasure_lair"),
            (assign, ":var_4", "trp_rb_guildsman"),
            (assign, ":var_5", "trp_singal_lair_leader"),
        (else_try),
            (eq, ":var_2", "pt_looter_lair"),
            (assign, ":var_4", "trp_looter"),
        (try_end),
        (store_current_scene, ":var_6"),
        (modify_visitors_at_site, ":var_6"),
        (try_begin),
            (eq, ":var_2", "pt_looter_lair"),
            (neg|eq, ":var_3", 0),
            (check_quest_active, "qst_save_relative_of_merchant"),
            (store_faction_of_party, ":var_7", "$g_starting_town"),
            (store_sub, ":var_8", ":var_7", "fac_kingdom_1"),
            (store_add, ":var_5", "trp_heretic_leader", ":var_8"),
            (add_visitors_to_current_scene, 2, ":var_5", 1),
        (else_try),
            (neg|eq, ":var_3", 0),
            (add_visitors_to_current_scene, 2, ":var_5", 1),
        (try_end),
        (store_random_in_range, ":var_9", 3, 11),
        (add_visitors_to_current_scene, ":var_9", ":var_4", 1),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_3, ":var_1"),
        (try_begin),
            (ge, ":var_0", 0),
            (agent_is_human, ":var_0"),
            (agent_get_troop_id, ":var_2", ":var_0"),
            (str_store_troop_name, s6, ":var_2"),
            (try_begin),
                (neg|agent_is_ally, ":var_0"),
                (party_add_members, "p_total_enemy_casualties", ":var_2", 1),
                (try_begin),
                    (eq, ":var_1", 1),
                    (party_wound_members, "p_total_enemy_casualties", ":var_2", 1),
                (try_end),
            (try_end),
            (party_add_members, "p_temp_casualties", ":var_2", 1),
            (eq, ":var_1", 1),
            (party_wound_members, "p_temp_casualties", ":var_2", 1),
        (try_end),
        (assign, ":var_3", 0),
        (try_for_agents, ":var_4"),
            (agent_is_non_player, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_is_alive, ":var_4"),
            (neg|agent_is_ally, ":var_4"),
            (val_add, ":var_3", 1),
        (try_end),
        (try_begin),
            (neg|gt, ":var_3", 2),
            (neg|gt, "$defender_reinforcement_stage", 1),
            (val_add, "$defender_reinforcement_stage", 1),
            (store_character_level, ":var_5", "trp_player"),
            (store_add, ":var_6", 5, ":var_5"),
            (val_div, ":var_6", 3),
            (try_begin),
                (ge, "$defender_reinforcement_stage", 2),
                (val_sub, ":var_6", "$bandits_spawned_extra"),
            (try_end),
            (party_get_template_id, ":var_7", "$g_encountered_party"),
            (store_random_in_range, ":var_8", 0, 2),
            (try_begin),
                (eq, ":var_7", "pt_sea_raider_lair"),
                (assign, ":var_9", "trp_sea_raider"),
                (assign, ":var_10", "trp_vanskerry_lair_leader"),
            (else_try),
                (eq, ":var_7", "pt_forest_bandit_lair"),
                (assign, ":var_9", "trp_forest_bandit"),
                (assign, ":var_10", "trp_heretic_lair_leader"),
            (else_try),
                (eq, ":var_7", "pt_mountain_bandit_lair"),
                (assign, ":var_9", "trp_mountain_bandit"),
                (assign, ":var_10", "trp_myst_lair_leader"),
            (else_try),
                (eq, ":var_7", "pt_snake_bandit_lair"),
                (assign, ":var_9", "trp_snake_armsman"),
                (assign, ":var_10", "trp_snake_lair_leader"),
            (else_try),
                (eq, ":var_7", "pt_steppe_bandit_lair"),
                (assign, ":var_9", "trp_steppe_bandit"),
                (assign, ":var_10", "trp_singal_lair_leader"),
            (else_try),
                (eq, ":var_7", "pt_treasure_lair"),
                (assign, ":var_9", "trp_rb_guildsman"),
                (assign, ":var_10", "trp_singal_lair_leader"),
            (else_try),
                (eq, ":var_7", "pt_looter_lair"),
                (assign, ":var_9", "trp_looter"),
            (try_end),
            (store_current_scene, ":var_11"),
            (modify_visitors_at_site, ":var_11"),
            (try_for_range, ":var_12", 0, ":var_6"),
                (store_random_in_range, ":var_13", 2, 11),
                (add_visitors_to_current_scene, ":var_13", ":var_9", 1),
                (neg|eq, ":var_7", "pt_looter_lair"),
                (neg|eq, ":var_8", 0),
                (eq, ":var_12", 0),
                (val_add, ":var_13", 1),
                (try_begin),
                    (eq, ":var_13", 11),
                    (assign, ":var_13", 2),
                (try_end),
                (add_visitors_to_current_scene, ":var_13", ":var_10", 1),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 4096),
        (set_party_battle_mode),
    ]),

    (2.000000, 0.000000, ti_once, 
    [
        (neg|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (party_get_template_id, ":var_0", "$g_encountered_party"),
        (try_begin),
            (eq, ":var_0", "pt_looter_lair"),
            (check_quest_active, "qst_save_relative_of_merchant"),
            (store_faction_of_party, ":var_1", "$g_starting_town"),
            (try_begin),
                (eq, ":var_1", "fac_kingdom_1"),
                (assign, ":var_2", "trp_relative_of_merchant_sarleon"),
            (else_try),
                (eq, ":var_1", "fac_kingdom_2"),
                (assign, ":var_2", "trp_relative_of_merchant_ravenstern"),
            (else_try),
                (eq, ":var_1", "fac_kingdom_3"),
                (assign, ":var_2", "trp_relative_of_merchant_dshar"),
            (else_try),
                (eq, ":var_1", "fac_kingdom_4"),
                (assign, ":var_2", "trp_relative_of_merchant_fierdsvain"),
            (else_try),
                (eq, ":var_1", "fac_kingdom_5"),
                (assign, ":var_2", "trp_relative_of_merchant_empire"),
            (try_end),
            (get_player_agent_no, ":var_3"),
            (agent_get_position, pos0, ":var_3"),
            (assign, ":var_4", 100000),
            (try_for_range, ":var_5", 1, 10),
                (entry_point_get_position, pos1, ":var_5"),
                (get_distance_between_positions, ":var_6", pos0, pos1),
                (neg|gt, ":var_6", ":var_4"),
                (ge, ":var_6", 1000),
                (assign, ":var_7", ":var_5"),
                (assign, ":var_4", ":var_6"),
            (try_end),
            (add_visitors_to_current_scene, ":var_7", ":var_2", 1, 0),
        (try_end),
    ]),

    (0.000000, 1.000000, ti_once, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_mini_map"),
        (start_presentation, "prsnt_mini_map"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (this_or_next|key_is_down, key_left_control),
            (key_is_down, key_right_control),
            (try_begin),
                (key_clicked, key_h),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (else_try),
                (this_or_next|key_is_down, key_left_alt),
                (key_is_down, key_right_alt),
                (key_clicked, key_f4),
                (val_or, "$g_achieve_bits_delay_popup", 16777216),
            (try_end),
        (try_end),
        (try_begin),
            (neg|is_presentation_active, "prsnt_battle"),
            (neg|is_presentation_active, "prsnt_mini_map"),
            (start_presentation, "prsnt_mini_map"),
        (try_end),
        (try_begin),
            (is_presentation_active, "prsnt_battle"),
            (call_script, "script_update_order_panel_statistics_and_map"),
        (else_try),
            (is_presentation_active, "prsnt_mini_map"),
            (neg|eq, "$g_option_show_minimap", 0),
            (call_script, "script_update_order_panel_map"),
            (call_script, "script_update_order_flags_on_map"),
        (try_end),
        (try_begin),
            (this_or_next|neg|eq, "$g_hp_bar_ally", 0),
            (neg|eq, "$g_hp_bar_enemy", 0),
            (is_presentation_active, "prsnt_mini_map"),
            (call_script, "script_update_agent_hp_bar"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (eq, "$g_option_show_killcount", 1),
        (start_presentation, "prsnt_killcount"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (assign, ":var_0", 0),
        (party_get_template_id, ":var_1", "$g_encountered_party"),
        (try_begin),
            (eq, ":var_1", "pt_looter_lair"),
            (check_quest_active, "qst_save_relative_of_merchant"),
            (this_or_next|main_hero_fallen),
            (eq, "$relative_of_merchant_is_found", 1),
            (assign, ":var_0", 1),
        (else_try),
            (this_or_next|neg|eq, ":var_1", "pt_looter_lair"),
            (neg|check_quest_active, "qst_save_relative_of_merchant"),
            (store_mission_timer_a, ":var_2"),
            (ge, ":var_2", 5),
            (this_or_next|main_hero_fallen),
            (num_active_teams_le, 1),
            (assign, ":var_0", 1),
        (try_end),
        (eq, ":var_0", 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
        (else_try),
            (party_set_slot, "$g_encountered_party", slot_party_ai_substate, 2),
        (try_end),
        (try_begin),
            (neg|main_hero_fallen),
            (party_get_template_id, ":var_0", "$g_encountered_party"),
            (eq, ":var_0", "pt_treasure_lair"),
            (display_message, "@The thieves guarding the treasure were beaten - find the treasure chest"),
        (else_try),
            (finish_mission),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_is_non_player, ":var_0"),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (agent_slot_eq, ":var_0", slot_agent_is_running_away, 0),
            (agent_get_slot, ":var_2", ":var_0", 247),
            (agent_get_wielded_item, ":var_3", ":var_0", 0),
            (try_begin),
                (gt, ":var_2", 0),
                (val_sub, ":var_2", 1),
                (agent_set_slot, ":var_0", 247, ":var_2"),
                (eq, ":var_2", 0),
                (agent_get_slot, ":var_4", ":var_0", 246),
                (gt, ":var_4", 0),
                (agent_set_slot, ":var_0", 246, 0),
                (agent_equip_item, ":var_0", ":var_4"),
                (agent_force_rethink, ":var_0"),
                (eq, ":var_3", -1),
                (agent_set_wielded_item, ":var_0", ":var_4"),
            (try_end),
            (neg|gt, ":var_2", 0),
            (agent_get_team, ":var_5", ":var_0"),
            (agent_get_division, ":var_6", ":var_0"),
            (team_get_weapon_usage_order, ":var_7", ":var_5", ":var_6"),
            (eq, ":var_7", 0),
            (agent_get_horse, ":var_8", ":var_0"),
            (gt, ":var_3", 0),
            (item_get_type, ":var_9", ":var_3"),
            (agent_get_ammo, ":var_10", ":var_0"),
            (store_skill_level, ":var_11", "skl_horse_archery", ":var_1"),
            (call_script, "script_agent_get_closest_enemy", ":var_0", 220),
            (assign, ":var_12", reg0),
            (assign, ":var_13", reg1),
            (assign, ":var_14", reg4),
            (try_begin),
                (gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_15", 0),
                (set_fixed_point_multiplier, 100),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (ge, ":var_11", 4),
                        (assign, ":var_15", 1),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (gt, ":var_12", 0),
                        (assign, ":var_15", -1),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_15", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (this_or_next|eq, ":var_9", 4),
                        (this_or_next|is_between, ":var_9", 8, 11),
                        (this_or_next|eq, ":var_9", 16),
                        (eq, ":var_9", 17),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_15", 1),
                    (neg|eq, "$g_option_horse_archer_ai", 0),
                    (assign, ":var_19", -1),
                    (assign, ":var_20", 0),
                    (try_for_range, ":var_21", 0, 4),
                        (agent_get_item_slot, ":var_22", ":var_0", ":var_21"),
                        (gt, ":var_22", -1),
                        (item_get_type, ":var_23", ":var_22"),
                        (try_begin),
                            (eq, ":var_23", 4),
                            (item_get_slot, ":var_24", ":var_22", 201),
                            (store_and, ":var_25", ":var_24", 2147483648),
                            (gt, ":var_25", 0),
                            (assign, ":var_20", 1),
                        (try_end),
                        (this_or_next|eq, ":var_23", 8),
                        (this_or_next|eq, ":var_23", 9),
                        (this_or_next|eq, ":var_23", 16),
                        (eq, ":var_23", 17),
                        (assign, ":var_19", ":var_22"),
                    (try_end),
                    (try_begin),
                        (eq, ":var_20", 0),
                        (ge, ":var_19", 0),
                        (ge, ":var_13", 600),
                        (team_get_hold_fire_order, ":var_26", ":var_5", ":var_6"),
                        (neg|eq, ":var_26", 1),
                        (call_script, "script_agent_wield_weapon", ":var_0", ":var_19"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (try_end),
            (else_try),
                (neg|gt, ":var_10", 0),
                (ge, ":var_8", 0),
                (assign, ":var_27", 0),
                (try_begin),
                    (set_fixed_point_multiplier, 10),
                    (agent_get_speed, pos1, ":var_0"),
                    (position_get_x, ":var_16", pos1),
                    (position_get_y, ":var_17", pos1),
                    (val_max, ":var_17", ":var_16"),
                    (item_get_slot, ":var_28", ":var_3", 17),
                    (val_sub, ":var_28", 10),
                    (try_begin),
                        (ge, ":var_17", 80),
                        (try_begin),
                            (ge, ":var_13", 500),
                            (assign, ":var_27", 1),
                        (try_end),
                    (else_try),
                        (neg|gt, ":var_17", 50),
                        (this_or_next|ge, ":var_12", 1),
                        (neg|gt, ":var_13", ":var_28"),
                        (assign, ":var_27", -1),
                    (try_end),
                    (try_begin),
                        (this_or_next|neg|gt, ":var_13", 200),
                        (neg|gt, ":var_13", ":var_28"),
                        (agent_get_speed, pos2, ":var_14"),
                        (position_get_x, ":var_29", pos2),
                        (position_get_y, ":var_30", pos2),
                        (val_max, ":var_30", ":var_29"),
                        (ge, ":var_30", 80),
                        (agent_get_slot, ":var_31", ":var_0", 245),
                        (val_add, ":var_31", 1),
                        (agent_set_slot, ":var_0", 245, ":var_31"),
                        (try_begin),
                            (gt, ":var_31", 1),
                            (assign, ":var_27", -1),
                        (try_end),
                    (else_try),
                        (agent_set_slot, ":var_0", 245, 0),
                    (try_end),
                (try_end),
                (try_begin),
                    (eq, ":var_27", -1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (eq, ":var_9", 4),
                        (item_get_slot, ":var_32", ":var_3", 200),
                        (store_and, ":var_33", ":var_32", 25165824),
                        (this_or_next|ge, ":var_12", 5),
                        (eq, ":var_33", 0),
                        (agent_get_attack_action, ":var_18", ":var_0"),
                        (neg|is_between, ":var_18", 2, 3),
                        (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                        (agent_force_rethink, ":var_0"),
                    (try_end),
                (else_try),
                    (eq, ":var_27", 1),
                    (try_begin),
                        (gt, ":var_3", 0),
                        (neg|eq, ":var_9", 4),
                        (try_for_range, ":var_34", 0, 4),
                            (agent_get_item_slot, ":var_35", ":var_0", ":var_34"),
                            (gt, ":var_35", 0),
                            (item_get_type, ":var_36", ":var_35"),
                            (eq, ":var_36", 4),
                            (agent_get_attack_action, ":var_18", ":var_0"),
                            (neg|is_between, ":var_18", 2, 3),
                            (call_script, "script_troop_can_use_item", ":var_1", ":var_35", 0),
                            (gt, reg0, 0),
                            (call_script, "script_agent_wield_weapon", ":var_0", ":var_35"),
                            (agent_force_rethink, ":var_0"),
                        (try_end),
                    (try_end),
                (try_end),
            (else_try),
                (neg|ge, ":var_8", 0),
                (eq, ":var_9", 4),
                (neg|gt, ":var_13", 190),
                (try_begin),
                    (assign, ":var_37", 1),
                    (assign, ":var_38", 0),
                    (assign, ":var_39", 4),
                    (try_for_range, ":var_40", 0, ":var_39"),
                        (agent_get_item_slot, ":var_41", ":var_0", ":var_40"),
                        (try_begin),
                            (ge, ":var_41", 0),
                            (item_get_type, ":var_42", ":var_41"),
                            (this_or_next|eq, ":var_42", 2),
                            (eq, ":var_42", 3),
                            (assign, ":var_37", 0),
                            (assign, ":var_39", 0),
                        (else_try),
                            (assign, ":var_38", 1),
                        (try_end),
                    (try_end),
                    (eq, ":var_37", 1),
                    (assign, ":var_43", -1),
                    (troop_get_inventory_capacity, ":var_39", ":var_1"),
                    (try_for_range, ":var_44", 0, ":var_39"),
                        (troop_get_inventory_slot, ":var_41", ":var_1", ":var_44"),
                        (gt, ":var_41", -1),
                        (item_get_type, ":var_42", ":var_41"),
                        (this_or_next|eq, ":var_42", 2),
                        (eq, ":var_42", 3),
                        (assign, ":var_43", ":var_41"),
                        (assign, ":var_39", 0),
                    (try_end),
                    (ge, ":var_43", 0),
                    (try_begin),
                        (eq, ":var_38", 0),
                        (agent_unequip_item, ":var_0", ":var_3"),
                    (try_end),
                    (agent_equip_item, ":var_0", ":var_43"),
                (try_end),
                (call_script, "script_agent_wield_best_of_equipped_short_weapon", ":var_0"),
                (agent_force_rethink, ":var_0"),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 5.000000, 
    [
    ],
    [
        (try_for_agents, ":var_0"),
            (assign, ":var_1", -1),
            (assign, ":var_2", 0),
            (agent_is_alive, ":var_0"),
            (agent_is_human, ":var_0"),
            (agent_get_horse, ":var_3", ":var_0"),
            (gt, ":var_3", -1),
            (agent_get_troop_id, ":var_4", ":var_0"),
            (neg|troop_is_hero, ":var_4"),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (gt, ":var_7", 0),
                (item_get_type, ":var_8", ":var_7"),
                (eq, ":var_8", 4),
                (assign, ":var_2", 1),
                (assign, ":var_5", 0),
            (try_end),
            (eq, ":var_2", 0),
            (assign, ":var_1", 4),
            (assign, ":var_5", 4),
            (try_for_range, ":var_6", 0, ":var_5"),
                (agent_get_item_slot, ":var_7", ":var_0", ":var_6"),
                (eq, ":var_7", -1),
                (call_script, "script_get_fitfull_weapon_for_empty_slot", ":var_4", ":var_1"),
                (assign, ":var_9", reg1),
                (gt, ":var_9", -1),
                (agent_equip_item, ":var_0", ":var_9"),
                (assign, ":var_5", 0),
            (try_end),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_v),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (set_show_messages, 0),
        (try_for_range, ":var_2", 0, 9),
            (class_is_listening_order, ":var_1", ":var_2"),
            (team_give_order, ":var_1", ":var_2", 0),
        (try_end),
        (get_player_agent_no, ":var_3"),
        (try_for_agents, ":var_4"),
            (agent_is_alive, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_get_team, ":var_5", ":var_4"),
            (eq, ":var_5", ":var_1"),
            (agent_get_division, ":var_2", ":var_4"),
            (class_is_listening_order, ":var_1", ":var_2"),
            (agent_get_horse, ":var_6", ":var_4"),
            (neg|gt, ":var_6", 0),
            (neg|eq, ":var_4", ":var_3"),
            (agent_set_is_alarmed, ":var_4", 0),
            (agent_get_slot, ":var_7", ":var_4", 250),
            (ge, ":var_7", 10),
            (try_begin),
                (agent_get_animation, ":var_8", ":var_4"),
                (assign, ":var_9", "anim_spearwall_hold"),
                (neg|eq, ":var_8", ":var_9"),
                (agent_set_animation, ":var_4", ":var_9"),
                (agent_get_position, pos1, ":var_4"),
                (agent_set_scripted_destination, ":var_4", pos1),
                (set_fixed_point_multiplier, 100),
                (agent_get_look_position, pos1, ":var_4"),
                (position_get_x, ":var_10", pos1),
                (position_get_y, ":var_11", pos1),
                (agent_set_slot, ":var_4", slot_agent_target_x_pos, ":var_10"),
                (agent_set_slot, ":var_4", slot_agent_target_y_pos, ":var_11"),
            (try_end),
        (try_end),
        (set_show_messages, 1),
    ]),

    (0.100000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (agent_get_horse, ":var_2", ":var_0"),
        (try_for_agents, ":var_3"),
            (agent_is_alive, ":var_3"),
            (agent_is_human, ":var_3"),
            (agent_slot_eq, ":var_3", slot_agent_is_running_away, 0),
            (agent_get_horse, ":var_4", ":var_3"),
            (neg|gt, ":var_4", 0),
            (agent_get_slot, ":var_5", ":var_3", 250),
            (agent_get_simple_behavior, ":var_6", ":var_3"),
            (agent_get_team, ":var_7", ":var_3"),
            (agent_get_class, ":var_8", ":var_3"),
            (team_get_movement_order, ":var_9", ":var_7", ":var_8"),
            (assign, ":var_10", 0),
            (agent_get_animation, ":var_11", ":var_3"),
            (try_begin),
                (neg|eq, ":var_7", ":var_1"),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (this_or_next|eq, ":var_9", 0),
                (eq, ":var_9", 11),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
                (neg|eq, ":var_3", ":var_0"),
                (assign, ":var_12", "anim_spearwall_hold"),
                (eq, ":var_11", ":var_12"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
                (assign, ":var_10", 0),
            (try_end),
            (try_begin),
                (eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (assign, ":var_10", 1),
            (try_end),
            (eq, ":var_10", 1),
            (agent_get_wielded_item, ":var_13", ":var_3", 0),
            (try_begin),
                (neg|ge, ":var_13", 0),
                (agent_get_wielded_item, ":var_13", ":var_3", 1),
            (try_end),
            (ge, ":var_13", 0),
            (item_get_type, ":var_14", ":var_13"),
            (eq, ":var_14", 4),
            (item_get_slot, ":var_15", ":var_13", 17),
            (try_begin),
                (eq, ":var_15", 0),
                (assign, ":var_15", 145),
            (try_end),
            (val_add, ":var_15", 10),
            (try_begin),
                (agent_get_speed, pos0, ":var_3"),
                (position_get_y, ":var_16", pos0),
                (position_get_x, ":var_17", pos0),
                (val_max, ":var_16", ":var_17"),
                (eq, ":var_16", 0),
                (agent_get_troop_id, ":var_18", ":var_3"),
                (store_proficiency_level, ":var_19", ":var_18", wpt_polearm),
                (store_character_level, ":var_20", ":var_18"),
                (ge, ":var_20", 12),
                (ge, ":var_19", 120),
                (item_get_slot, ":var_21", ":var_13", 200),
                (store_and, ":var_22", ":var_21", 256),
                (gt, ":var_22", 0),
                (assign, ":var_10", 1),
                (agent_get_wielded_item, ":var_23", ":var_3", 1),
                (try_begin),
                    (gt, ":var_23", 0),
                    (item_get_type, ":var_24", ":var_23"),
                    (eq, ":var_24", 7),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_10", 1),
                (try_begin),
                    (neg|ge, ":var_5", 50),
                    (val_add, ":var_5", 1),
                    (agent_set_slot, ":var_3", 250, ":var_5"),
                (try_end),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
            (try_end),
            (this_or_next|eq, ":var_3", ":var_0"),
            (ge, ":var_5", 20),
            (try_begin),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_get_position, pos1, ":var_3"),
                (agent_set_scripted_destination, ":var_3", pos1),
                (agent_set_is_alarmed, ":var_3", 0),
                (agent_get_slot, ":var_25", ":var_3", slot_agent_target_x_pos),
                (agent_get_slot, ":var_26", ":var_3", slot_agent_target_y_pos),
                (init_position, pos2),
                (position_set_x, pos2, ":var_25"),
                (position_set_y, pos2, ":var_26"),
                (agent_set_look_target_position, ":var_3", pos2),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (assign, ":var_27", -1),
            (assign, ":var_28", -1),
            (agent_get_position, pos1, ":var_3"),
            (try_for_agents, ":var_29"),
                (agent_is_alive, ":var_29"),
                (neg|agent_is_human, ":var_29"),
                (agent_get_rider, ":var_30", ":var_29"),
                (ge, ":var_30", 0),
                (agent_get_team, ":var_31", ":var_30"),
                (teams_are_enemies, ":var_7", ":var_31"),
                (agent_get_position, pos2, ":var_29"),
                (get_distance_between_positions, ":var_32", pos1, pos2),
                (neg|ge, ":var_32", ":var_15"),
                (neg|position_is_behind_position, 2, 1),
                (agent_get_speed, pos4, ":var_29"),
                (position_get_x, ":var_33", pos4),
                (position_get_y, ":var_34", pos4),
                (this_or_next|gt, ":var_33", 350),
                (gt, ":var_34", 350),
                (get_angle_between_positions, ":var_35", pos1, pos2),
                (val_abs, ":var_35"),
                (convert_from_fixed_point, ":var_35"),
                (is_between, ":var_35", 150, 181),
                (assign, ":var_27", ":var_29"),
                (assign, ":var_28", ":var_30"),
            (try_end),
            (try_begin),
                (eq, ":var_27", -1),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (store_sub, ":var_32", ":var_15", 20),
                (call_script, "script_agent_get_closest_enemy", ":var_3", ":var_32"),
                (ge, reg0, 1),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_set_slot, ":var_3", 250, 0),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
            (try_end),
            (gt, ":var_27", -1),
            (val_mul, ":var_33", ":var_33"),
            (val_mul, ":var_34", ":var_34"),
            (store_add, ":var_36", ":var_33", ":var_34"),
            (store_sqrt, ":var_36", ":var_36"),
            (val_div, ":var_36", 100),
            (store_mul, ":var_37", ":var_36", 4),
            (try_begin),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
            (try_end),
            (agent_clear_scripted_mode, ":var_3"),
            (agent_set_slot, ":var_3", 250, 0),
            (agent_play_sound, ":var_27", "snd_metal_hit_high_armor_high_damage"),
            (store_agent_hit_points, ":var_38", ":var_27", 1),
            (store_sub, ":var_39", ":var_38", ":var_37"),
            (val_max, ":var_39", 0),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27", ":var_37"),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27"),
            (store_agent_hit_points, ":var_39", ":var_27", 1),
            (store_agent_hit_points, ":var_40", ":var_28", 1),
            (try_begin),
                (gt, ":var_39", 0),
                (agent_set_animation, ":var_27", "anim_horse_rear"),
            (else_try),
                (neg|gt, ":var_39", 0),
                (agent_deliver_damage_to_agent, ":var_27", ":var_28"),
            (try_end),
            (store_agent_hit_points, ":var_41", ":var_28", 1),
            (try_begin),
                (eq, ":var_27", ":var_2"),
                (val_sub, ":var_38", ":var_39"),
                (assign, reg1, ":var_38"),
                (display_message, "@Your horse received {reg1} damage from a braced spear!", 0xFF4040),
                (try_begin),
                    (val_sub, ":var_40", ":var_41"),
                    (gt, ":var_40", 0),
                    (assign, reg2, ":var_40"),
                    (display_message, "@You received {reg2} damage from a braced spear!", 0xFF4040),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),
        (this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),
        (game_key_clicked, gk_sheath_weapon),
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_animation, ":var_1", ":var_0"),
        (eq, ":var_1", "anim_spearwall_hold"),
        (agent_set_animation, ":var_0", "anim_spearwall_hold_recoil"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_b),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (try_begin),
            (neg|ge, ":var_1", 0),
            (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (try_end),
        (ge, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 4),
        (item_get_slot, ":var_3", ":var_1", 200),
        (store_and, ":var_4", ":var_3", 256),
        (gt, ":var_4", 0),
        (assign, ":var_5", 1),
        (agent_get_wielded_item, ":var_6", ":var_0", 1),
        (try_begin),
            (gt, ":var_6", 0),
            (item_get_type, ":var_7", ":var_6"),
            (eq, ":var_7", 7),
            (assign, ":var_5", 0),
        (try_end),
        (eq, ":var_5", 1),
        (agent_get_horse, ":var_8", ":var_0"),
        (neg|gt, ":var_8", 0),
        (agent_get_animation, ":var_9", ":var_0"),
        (neg|eq, ":var_9", "anim_spearwall_hold"),
        (neg|eq, ":var_9", "anim_spearwall_hold_recoil"),
        (str_store_item_name, s1, ":var_1"),
        (display_message, "@Bracing {s1} for charge.", 0x6495ED),
        (agent_set_animation, ":var_0", "anim_spearwall_hold"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"alley_fight", 2, 8, 
"Alley_fight",
[(0, mtef_team_0|mtef_use_exact_number, af_override_horse, 16, 7, []),
(1, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(2, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
(3, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 20, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cant_use_inventory_now"),
    ],
    [
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (get_player_agent_no, ":var_1"),
        (neg|eq, ":var_0", ":var_1"),
        (assign, "$g_main_attacker_agent", ":var_0"),
        (agent_ai_set_aggressiveness, ":var_0", 199),
        (try_begin),
            (agent_get_troop_id, ":var_2", ":var_0"),
            (is_between, ":var_2", "trp_sarleon_merchant", "trp_startup_merchants_end"),
            (agent_set_team, ":var_0", 7),
            (team_set_relation, 0, 7, 0),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$talked_with_merchant", 0),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_position, pos0, ":var_0"),
        (try_for_agents, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (is_between, ":var_2", "trp_sarleon_merchant", "trp_startup_merchants_end"),
            (agent_set_scripted_destination, ":var_1", pos0),
            (agent_get_position, pos1, ":var_1"),
            (get_distance_between_positions, ":var_3", pos0, pos1),
            (neg|gt, ":var_3", 200),
            (assign, "$talk_context", 11),
            (start_mission_conversation, ":var_2"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (get_player_agent_no, ":var_0"),
        (ge, "$g_main_attacker_agent", 0),
        (ge, ":var_0", 0),
        (agent_is_active, "$g_main_attacker_agent"),
        (agent_is_active, ":var_0"),
        (agent_get_position, pos0, ":var_0"),
        (agent_get_position, pos1, "$g_main_attacker_agent"),
        (get_distance_between_positions, ":var_1", pos0, pos1),
        (ge, ":var_1", 5),
        (agent_set_scripted_destination, "$g_main_attacker_agent", pos0),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (display_message, "str_cannot_leave_now"),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (call_script, "script_music_set_situation_with_culture", 4096),
        (set_party_battle_mode),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
        (neg|main_hero_fallen),
        (num_active_teams_le, 1),
    ],
    [
        (store_faction_of_party, ":var_0", "$g_starting_town"),
        (try_begin),
            (eq, ":var_0", "fac_kingdom_1"),
            (assign, ":var_1", "trp_sarleon_merchant"),
        (else_try),
            (eq, ":var_0", "fac_kingdom_2"),
            (assign, ":var_1", "trp_ravenstern_merchant"),
        (else_try),
            (eq, ":var_0", "fac_kingdom_3"),
            (assign, ":var_1", "trp_dshar_merchant"),
        (else_try),
            (eq, ":var_0", "fac_kingdom_4"),
            (assign, ":var_1", "trp_fierdsvain_merchant"),
        (else_try),
            (eq, ":var_0", "fac_kingdom_5"),
            (assign, ":var_1", "trp_empire_merchant"),
        (try_end),
        (add_visitors_to_current_scene, 3, ":var_1", 1, 0),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
        (eq, "$talked_with_merchant", 1),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (assign, "$g_killed_first_bandit", 0),
        (else_try),
            (assign, "$g_killed_first_bandit", 1),
        (try_end),
        (finish_mission),
        (assign, "$g_main_attacker_agent", 0),
        (assign, "$talked_with_merchant", 1),
        (assign, "$current_startup_quest_phase", 1),
        (change_screen_return),
        (set_trigger_result, 1),
        (get_player_agent_no, ":var_0"),
        (store_agent_hit_points, ":var_1", ":var_0"),
        (try_begin),
            (neg|ge, ":var_1", 90),
            (agent_set_hit_points, ":var_0", 90),
        (try_end),
    ]),

    (1.000000, 3.000000, ti_once, 
    [
        (main_hero_fallen),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (assign, "$g_killed_first_bandit", 0),
        (else_try),
            (assign, "$g_killed_first_bandit", 1),
        (try_end),
        (finish_mission),
        (assign, "$g_main_attacker_agent", 0),
        (assign, "$talked_with_merchant", 1),
        (assign, "$current_startup_quest_phase", 1),
        (change_screen_return),
        (set_trigger_result, 1),
        (get_player_agent_no, ":var_0"),
        (store_agent_hit_points, ":var_1", ":var_0"),
        (try_begin),
            (neg|ge, ":var_1", 90),
            (agent_set_hit_points, ":var_0", 90),
        (try_end),
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_v),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (set_show_messages, 0),
        (try_for_range, ":var_2", 0, 9),
            (class_is_listening_order, ":var_1", ":var_2"),
            (team_give_order, ":var_1", ":var_2", 0),
        (try_end),
        (get_player_agent_no, ":var_3"),
        (try_for_agents, ":var_4"),
            (agent_is_alive, ":var_4"),
            (agent_is_human, ":var_4"),
            (agent_get_team, ":var_5", ":var_4"),
            (eq, ":var_5", ":var_1"),
            (agent_get_division, ":var_2", ":var_4"),
            (class_is_listening_order, ":var_1", ":var_2"),
            (agent_get_horse, ":var_6", ":var_4"),
            (neg|gt, ":var_6", 0),
            (neg|eq, ":var_4", ":var_3"),
            (agent_set_is_alarmed, ":var_4", 0),
            (agent_get_slot, ":var_7", ":var_4", 250),
            (ge, ":var_7", 10),
            (try_begin),
                (agent_get_animation, ":var_8", ":var_4"),
                (assign, ":var_9", "anim_spearwall_hold"),
                (neg|eq, ":var_8", ":var_9"),
                (agent_set_animation, ":var_4", ":var_9"),
                (agent_get_position, pos1, ":var_4"),
                (agent_set_scripted_destination, ":var_4", pos1),
                (set_fixed_point_multiplier, 100),
                (agent_get_look_position, pos1, ":var_4"),
                (position_get_x, ":var_10", pos1),
                (position_get_y, ":var_11", pos1),
                (agent_set_slot, ":var_4", slot_agent_target_x_pos, ":var_10"),
                (agent_set_slot, ":var_4", slot_agent_target_y_pos, ":var_11"),
            (try_end),
        (try_end),
        (set_show_messages, 1),
    ]),

    (0.100000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_team, ":var_1", ":var_0"),
        (agent_get_horse, ":var_2", ":var_0"),
        (try_for_agents, ":var_3"),
            (agent_is_alive, ":var_3"),
            (agent_is_human, ":var_3"),
            (agent_slot_eq, ":var_3", slot_agent_is_running_away, 0),
            (agent_get_horse, ":var_4", ":var_3"),
            (neg|gt, ":var_4", 0),
            (agent_get_slot, ":var_5", ":var_3", 250),
            (agent_get_simple_behavior, ":var_6", ":var_3"),
            (agent_get_team, ":var_7", ":var_3"),
            (agent_get_class, ":var_8", ":var_3"),
            (team_get_movement_order, ":var_9", ":var_7", ":var_8"),
            (assign, ":var_10", 0),
            (agent_get_animation, ":var_11", ":var_3"),
            (try_begin),
                (neg|eq, ":var_7", ":var_1"),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (this_or_next|eq, ":var_9", 0),
                (eq, ":var_9", 11),
                (this_or_next|eq, ":var_6", 0),
                (this_or_next|eq, ":var_6", 9),
                (eq, ":var_6", 1),
                (assign, ":var_10", 1),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
                (neg|eq, ":var_3", ":var_0"),
                (assign, ":var_12", "anim_spearwall_hold"),
                (eq, ":var_11", ":var_12"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
                (assign, ":var_10", 0),
            (try_end),
            (try_begin),
                (eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (assign, ":var_10", 1),
            (try_end),
            (eq, ":var_10", 1),
            (agent_get_wielded_item, ":var_13", ":var_3", 0),
            (try_begin),
                (neg|ge, ":var_13", 0),
                (agent_get_wielded_item, ":var_13", ":var_3", 1),
            (try_end),
            (ge, ":var_13", 0),
            (item_get_type, ":var_14", ":var_13"),
            (eq, ":var_14", 4),
            (item_get_slot, ":var_15", ":var_13", 17),
            (try_begin),
                (eq, ":var_15", 0),
                (assign, ":var_15", 145),
            (try_end),
            (val_add, ":var_15", 10),
            (try_begin),
                (agent_get_speed, pos0, ":var_3"),
                (position_get_y, ":var_16", pos0),
                (position_get_x, ":var_17", pos0),
                (val_max, ":var_16", ":var_17"),
                (eq, ":var_16", 0),
                (agent_get_troop_id, ":var_18", ":var_3"),
                (store_proficiency_level, ":var_19", ":var_18", wpt_polearm),
                (store_character_level, ":var_20", ":var_18"),
                (ge, ":var_20", 12),
                (ge, ":var_19", 120),
                (item_get_slot, ":var_21", ":var_13", 200),
                (store_and, ":var_22", ":var_21", 256),
                (gt, ":var_22", 0),
                (assign, ":var_10", 1),
                (agent_get_wielded_item, ":var_23", ":var_3", 1),
                (try_begin),
                    (gt, ":var_23", 0),
                    (item_get_type, ":var_24", ":var_23"),
                    (eq, ":var_24", 7),
                    (assign, ":var_10", 0),
                (try_end),
                (eq, ":var_10", 1),
                (try_begin),
                    (neg|ge, ":var_5", 50),
                    (val_add, ":var_5", 1),
                    (agent_set_slot, ":var_3", 250, ":var_5"),
                (try_end),
            (else_try),
                (agent_set_slot, ":var_3", 250, 0),
            (try_end),
            (this_or_next|eq, ":var_3", ":var_0"),
            (ge, ":var_5", 20),
            (try_begin),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_get_position, pos1, ":var_3"),
                (agent_set_scripted_destination, ":var_3", pos1),
                (agent_set_is_alarmed, ":var_3", 0),
                (agent_get_slot, ":var_25", ":var_3", slot_agent_target_x_pos),
                (agent_get_slot, ":var_26", ":var_3", slot_agent_target_y_pos),
                (init_position, pos2),
                (position_set_x, pos2, ":var_25"),
                (position_set_y, pos2, ":var_26"),
                (agent_set_look_target_position, ":var_3", pos2),
            (try_end),
            (set_fixed_point_multiplier, 100),
            (assign, ":var_27", -1),
            (assign, ":var_28", -1),
            (agent_get_position, pos1, ":var_3"),
            (try_for_agents, ":var_29"),
                (agent_is_alive, ":var_29"),
                (neg|agent_is_human, ":var_29"),
                (agent_get_rider, ":var_30", ":var_29"),
                (ge, ":var_30", 0),
                (agent_get_team, ":var_31", ":var_30"),
                (teams_are_enemies, ":var_7", ":var_31"),
                (agent_get_position, pos2, ":var_29"),
                (get_distance_between_positions, ":var_32", pos1, pos2),
                (neg|ge, ":var_32", ":var_15"),
                (neg|position_is_behind_position, 2, 1),
                (agent_get_speed, pos4, ":var_29"),
                (position_get_x, ":var_33", pos4),
                (position_get_y, ":var_34", pos4),
                (this_or_next|gt, ":var_33", 350),
                (gt, ":var_34", 350),
                (get_angle_between_positions, ":var_35", pos1, pos2),
                (val_abs, ":var_35"),
                (convert_from_fixed_point, ":var_35"),
                (is_between, ":var_35", 150, 181),
                (assign, ":var_27", ":var_29"),
                (assign, ":var_28", ":var_30"),
            (try_end),
            (try_begin),
                (eq, ":var_27", -1),
                (neg|eq, ":var_3", ":var_0"),
                (eq, ":var_11", "anim_spearwall_hold"),
                (store_sub, ":var_32", ":var_15", 20),
                (call_script, "script_agent_get_closest_enemy", ":var_3", ":var_32"),
                (ge, reg0, 1),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
                (agent_set_slot, ":var_3", 250, 0),
                (agent_clear_scripted_mode, ":var_3"),
                (agent_force_rethink, ":var_3"),
            (try_end),
            (gt, ":var_27", -1),
            (val_mul, ":var_33", ":var_33"),
            (val_mul, ":var_34", ":var_34"),
            (store_add, ":var_36", ":var_33", ":var_34"),
            (store_sqrt, ":var_36", ":var_36"),
            (val_div, ":var_36", 100),
            (store_mul, ":var_37", ":var_36", 4),
            (try_begin),
                (eq, ":var_11", "anim_spearwall_hold"),
                (agent_set_animation, ":var_3", "anim_spearwall_hold_recoil"),
            (try_end),
            (agent_clear_scripted_mode, ":var_3"),
            (agent_set_slot, ":var_3", 250, 0),
            (agent_play_sound, ":var_27", "snd_metal_hit_high_armor_high_damage"),
            (store_agent_hit_points, ":var_38", ":var_27", 1),
            (store_sub, ":var_39", ":var_38", ":var_37"),
            (val_max, ":var_39", 0),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27", ":var_37"),
            (agent_deliver_damage_to_agent, ":var_3", ":var_27"),
            (store_agent_hit_points, ":var_39", ":var_27", 1),
            (store_agent_hit_points, ":var_40", ":var_28", 1),
            (try_begin),
                (gt, ":var_39", 0),
                (agent_set_animation, ":var_27", "anim_horse_rear"),
            (else_try),
                (neg|gt, ":var_39", 0),
                (agent_deliver_damage_to_agent, ":var_27", ":var_28"),
            (try_end),
            (store_agent_hit_points, ":var_41", ":var_28", 1),
            (try_begin),
                (eq, ":var_27", ":var_2"),
                (val_sub, ":var_38", ":var_39"),
                (assign, reg1, ":var_38"),
                (display_message, "@Your horse received {reg1} damage from a braced spear!", 0xFF4040),
                (try_begin),
                    (val_sub, ":var_40", ":var_41"),
                    (gt, ":var_40", 0),
                    (assign, reg2, ":var_40"),
                    (display_message, "@You received {reg2} damage from a braced spear!", 0xFF4040),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (this_or_next|game_key_clicked, gk_attack),
        (this_or_next|game_key_clicked, gk_defend),
        (this_or_next|game_key_clicked, gk_move_forward),
        (this_or_next|game_key_clicked, gk_move_backward),
        (this_or_next|game_key_clicked, gk_move_left),
        (this_or_next|game_key_clicked, gk_move_right),
        (this_or_next|game_key_clicked, gk_equip_primary_weapon),
        (this_or_next|game_key_clicked, gk_equip_secondary_weapon),
        (this_or_next|game_key_clicked, gk_action),
        (game_key_clicked, gk_sheath_weapon),
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_get_animation, ":var_1", ":var_0"),
        (eq, ":var_1", "anim_spearwall_hold"),
        (agent_set_animation, ":var_0", "anim_spearwall_hold_recoil"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_spearwall", 1),
        (key_clicked, key_b),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_wielded_item, ":var_1", ":var_0", 0),
        (try_begin),
            (neg|ge, ":var_1", 0),
            (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (try_end),
        (ge, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 4),
        (item_get_slot, ":var_3", ":var_1", 200),
        (store_and, ":var_4", ":var_3", 256),
        (gt, ":var_4", 0),
        (assign, ":var_5", 1),
        (agent_get_wielded_item, ":var_6", ":var_0", 1),
        (try_begin),
            (gt, ":var_6", 0),
            (item_get_type, ":var_7", ":var_6"),
            (eq, ":var_7", 7),
            (assign, ":var_5", 0),
        (try_end),
        (eq, ":var_5", 1),
        (agent_get_horse, ":var_8", ":var_0"),
        (neg|gt, ":var_8", 0),
        (agent_get_animation, ":var_9", ":var_0"),
        (neg|eq, ":var_9", "anim_spearwall_hold"),
        (neg|eq, ":var_9", "anim_spearwall_hold_recoil"),
        (str_store_item_name, s1, ":var_1"),
        (display_message, "@Bracing {s1} for charge.", 0x6495ED),
        (agent_set_animation, ":var_0", "anim_spearwall_hold"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"meeting_merchant", 0, -1, 
"Meeting_with_the_merchant",
[(0, mtef_team_0, af_override_horse, 0, 1, []),
(1, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(2, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(5, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(9, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (try_begin),
            (agent_get_troop_id, ":var_1", ":var_0"),
            (is_between, ":var_1", "trp_sarleon_merchant", "trp_startup_merchants_end"),
            (agent_set_team, ":var_0", 7),
            (team_set_relation, 0, 7, 0),
        (try_end),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
    ],
    [
        (assign, "$dialog_with_merchant_ended", 0),
        (store_current_scene, ":var_0"),
        (scene_set_slot, ":var_0", 0, 1),
        (try_begin),
            (eq, "$sneaked_into_town", 1),
            (call_script, "script_music_set_situation_with_culture", 16384),
        (else_try),
            (eq, "$talk_context", 14),
            (call_script, "script_music_set_situation_with_culture", 512),
        (else_try),
            (call_script, "script_music_set_situation_with_culture", 8192),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (assign, ":var_0", 0),
        (try_begin),
            (ge, "$dialog_with_merchant_ended", 6),
            (assign, ":var_0", 1),
        (else_try),
            (ge, "$dialog_with_merchant_ended", 1),
            (neg|conversation_screen_is_active),
            (try_begin),
                (eq, "$dialog_with_merchant_ended", 1),
                (check_quest_active, "qst_collect_men"),
                (dialog_box, "str_start_up_first_quest", "@Tutorial"),
            (try_end),
            (val_add, "$dialog_with_merchant_ended", 1),
            (assign, ":var_0", 0),
        (try_end),
        (try_begin),
            (conversation_screen_is_active),
            (tutorial_message, -1),
            (assign, ":var_0", 0),
        (try_end),
        (eq, ":var_0", 1),
    ],
    [
        (tutorial_message_set_size, 17, 17),
        (tutorial_message_set_position, 500, 650),
        (tutorial_message_set_center_justify, 0),
        (tutorial_message_set_background, 1),
        (tutorial_message, "str_press_tab_to_exit_from_town"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (set_trigger_result, 1),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (gt, "$dialog_with_merchant_ended", 0),
            (assign, ":var_0", 0),
            (party_get_position, pos1, "$current_town"),
            (try_for_range, ":var_1", 0, 10),
                (map_get_random_position_around_position, 0, pos1, pos2),
                (get_distance_between_positions, ":var_2", pos0, pos1),
                (ge, ":var_2", ":var_0"),
                (assign, ":var_0", ":var_2"),
                (copy_position, pos2, pos0),
            (try_end),
            (party_set_position, "p_main_party", pos2),
            (finish_mission),
            (assign, "$current_startup_quest_phase", 2),
            (tutorial_message, -1),
            (tutorial_message_set_background, 0),
            (change_screen_map),
            (try_begin),
                (check_quest_finished, "qst_save_town_from_bandits"),
                (assign, "$g_do_one_more_meeting_with_merchant", 1),
            (else_try),
                (set_spawn_radius, 50),
                (try_for_range, ":var_1", 0, 20),
                    (spawn_around_party, "p_main_party", "pt_looters"),
                (try_end),
            (try_end),
            (set_trigger_result, 1),
        (else_try),
            (display_message, "str_cannot_leave_now"),
        (try_end),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),


],),

(
"town_fight", 0, -1, 
"Town_Fight",
[(0, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(1, mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, []),
(2, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(3, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(4, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(5, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(6, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(7, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(8, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(9, mtef_visitor_source, af_override_horse, 0, 1, []),
(10, mtef_visitor_source, af_override_horse, 0, 1, []),
(11, mtef_visitor_source|mtef_team_1, af_override_horse, 0, 1, []),
(12, mtef_visitor_source|mtef_team_1, af_override_horse, 0, 1, []),
(13, mtef_visitor_source|mtef_team_1, af_override_horse, 0, 1, []),
(14, mtef_visitor_source, af_override_horse, 0, 1, []),
(15, mtef_visitor_source, af_override_horse, 0, 1, []),
(16, mtef_visitor_source, af_override_horse, 0, 1, []),
(17, mtef_visitor_source, af_override_horse, 0, 1, []),
(18, mtef_visitor_source, af_override_horse, 0, 1, []),
(19, mtef_visitor_source, af_override_horse, 0, 1, []),
(20, mtef_visitor_source, af_override_horse, 0, 1, []),
(21, mtef_visitor_source|mtef_team_1, af_override_horse, 0, 1, []),
(22, mtef_visitor_source|mtef_team_1, af_override_horse, 0, 1, []),
(23, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(24, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(25, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(26, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(27, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(28, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(29, mtef_visitor_source, af_override_horse, 0, 1, []),
(30, mtef_visitor_source, af_override_horse, 0, 1, []),
(31, mtef_visitor_source, af_override_horse, 0, 1, []),
(32, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(33, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(34, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(35, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(36, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(37, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(38, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(39, mtef_visitor_source|mtef_team_0, af_override_horse, 0, 1, []),
(40, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, af_override_horse, 16, 1, []),
],
[
    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_get_troop_id, ":var_1", ":var_0"),
        (call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":var_0", ":var_1"),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (agent_set_team, ":var_0", 0),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (mission_disable_talk),
        (assign, "$g_main_attacker_agent", 0),
        (set_party_battle_mode),
        (assign, "$number_of_bandits_killed_by_player", 0),
        (assign, "$number_of_civilian_loses", 0),
        (set_fixed_point_multiplier, 100),
    ]),

    (1.000000, 0.000000, ti_once, 
    [
        (call_script, "script_init_town_walker_agents"),
    ],
    [
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (try_begin),
            (agent_get_team, ":var_2", ":var_0"),
            (eq, ":var_2", 1),
            (get_player_agent_no, ":var_3"),
            (eq, ":var_3", ":var_1"),
            (val_add, "$number_of_bandits_killed_by_player", 1),
        (else_try),
            (eq, ":var_2", 0),
            (val_add, "$number_of_civilian_loses", 1),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (neg|ge, "$merchant_sign_count", 8),
        (val_add, "$merchant_sign_count", 1),
        (try_begin),
            (eq, "$merchant_sign_count", 2),
            (get_player_agent_no, ":var_0"),
            (try_for_agents, ":var_1"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (ge, ":var_2", "trp_sarleon_merchant"),
                (neg|ge, ":var_2", "trp_startup_merchants_end"),
                (assign, "$g_city_merchant_troop_id", ":var_2"),
                (assign, "$g_city_merchant_agent_id", ":var_1"),
                (agent_get_position, pos0, ":var_0"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_3", -1000),
                (try_for_range, ":var_4", 0, 64),
                    (entry_point_get_position, pos6, ":var_4"),
                    (get_distance_between_positions, ":var_5", pos0, pos6),
                    (get_distance_between_positions, ":var_6", pos1, pos6),
                    (store_sub, ":var_7", ":var_6", ":var_5"),
                    (ge, ":var_6", 15),
                    (ge, ":var_7", ":var_3"),
                    (copy_position, pos2, pos6),
                    (assign, ":var_3", ":var_7"),
                (try_end),
                (agent_set_scripted_destination, ":var_1", pos2, 0),
                (agent_set_speed_limit, ":var_1", 10),
            (try_end),
        (else_try),
            (eq, "$merchant_sign_count", 5),
            (get_player_agent_no, ":var_0"),
            (agent_get_position, pos0, ":var_0"),
            (agent_set_scripted_destination, "$g_city_merchant_agent_id", pos0, 0),
            (agent_set_speed_limit, "$g_city_merchant_agent_id", 10),
        (else_try),
            (eq, "$merchant_sign_count", 7),
            (agent_clear_scripted_mode, "$g_city_merchant_agent_id"),
            (assign, "$talk_context", 0),
            (start_mission_conversation, "$g_city_merchant_troop_id"),
        (try_end),
    ],
    [
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (ge, "$merchant_sign_count", 8),
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_get_team, ":var_2", ":var_1"),
            (eq, ":var_2", 0),
            (agent_get_position, pos0, ":var_1"),
            (assign, ":var_3", 10000),
            (try_for_agents, ":var_4"),
                (agent_is_alive, ":var_4"),
                (agent_get_team, ":var_5", ":var_4"),
                (eq, ":var_5", 1),
                (agent_get_position, pos1, ":var_4"),
                (get_distance_between_positions, ":var_6", pos0, pos1),
                (neg|gt, ":var_6", ":var_3"),
                (assign, ":var_3", ":var_6"),
                (copy_position, pos2, pos1),
            (try_end),
            (assign, reg1, ":var_6"),
            (try_begin),
                (neg|gt, ":var_3", 500),
                (agent_clear_scripted_mode, ":var_1"),
            (else_try),
                (neg|ge, ":var_3", 10000),
                (agent_set_scripted_destination, ":var_1", pos2, 0),
            (try_end),
        (try_end),
    ]),

    (3.000000, 0.000000, 0.000000, 
    [
        (neg|ge, "$merchant_sign_count", 8),
        (call_script, "script_tick_town_walkers"),
    ],
    [
    ]),

    (2.000000, 0.000000, 0.000000, 
    [
        (call_script, "script_center_ambiance_sounds"),
    ],
    [
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_change_banners_and_chest"),
    ]),

    (1.000000, 4.000000, ti_once, 
    [
        (this_or_next|main_hero_fallen),
        (num_active_teams_le, 1),
        (ge, "$merchant_sign_count", 8),
    ],
    [
        (try_begin),
            (main_hero_fallen),
            (assign, "$g_killed_first_bandit", 0),
        (else_try),
            (assign, "$g_killed_first_bandit", 1),
        (try_end),
        (assign, "$current_startup_quest_phase", 4),
        (mission_enable_talk),
        (finish_mission),
        (unlock_achievement, 6),
        (change_screen_return),
        (set_trigger_result, 1),
    ]),

    (ti_inventory_key_pressed, 0.000000, 0.000000, 
    [
        (try_begin),
            (eq, "$g_mt_mode", 0),
            (set_trigger_result, 1),
        (else_try),
            (eq, "$g_mt_mode", 1),
            (display_message, "str_cant_use_inventory_disguised"),
        (else_try),
            (display_message, "str_cant_use_inventory_now"),
        (try_end),
    ],
    [
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
        (display_message, "str_cannot_leave_now"),
    ],
    [
    ]),

    (ti_on_agent_hit, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (store_trigger_param_3, ":var_2"),
        (assign, ":var_3", ":var_2"),
        (try_begin),
            (agent_is_human, ":var_1"),
            (assign, ":var_4", reg0),
            (gt, ":var_4", -1),
            (try_begin),
                (item_get_slot, ":var_5", ":var_4", 222),
                (store_and, ":var_6", ":var_5", 16711680),
                (val_div, ":var_6", 65536),
                (store_and, ":var_7", ":var_5", 65535),
                (try_begin),
                    (store_and, ":var_8", ":var_5", 16777216),
                    (gt, ":var_8", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (store_agent_hit_points, ":var_10", ":var_0", 1),
                    (val_add, ":var_3", ":var_10"),
                    (particle_system_burst, "psys_fire_sparks_up_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left_red", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right_red", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_11", ":var_5", 33554432),
                    (gt, ":var_11", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (val_add, ":var_3", ":var_7"),
                    (particle_system_burst, "psys_fire_sparks_up", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_down", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_left", pos0, 100),
                    (particle_system_burst, "psys_fire_sparks_right", pos0, 100),
                (try_end),
                (try_begin),
                    (store_and, ":var_12", ":var_5", 67108864),
                    (gt, ":var_12", 0),
                    (store_random_in_range, ":var_9", 0, 100),
                    (neg|ge, ":var_9", ":var_6"),
                    (assign, ":var_13", ":var_7"),
                    (store_mul, ":var_14", ":var_3", ":var_13"),
                    (val_div, ":var_14", 100),
                    (try_begin),
                        (gt, ":var_14", 50),
                        (assign, ":var_14", 50),
                    (try_end),
                    (store_agent_hit_points, ":var_15", ":var_1", 1),
                    (val_add, ":var_15", ":var_14"),
                    (agent_set_hit_points, ":var_1", ":var_15", 1),
                (try_end),
            (try_end),
        (try_end),
        (set_trigger_result, ":var_3"),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
        (key_is_down, key_middle_mouse_button),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (neg|agent_slot_ge, ":var_0", 249, 1),
        (agent_get_wielded_item, ":var_1", ":var_0", 1),
        (gt, ":var_1", 0),
        (item_get_type, ":var_2", ":var_1"),
        (eq, ":var_2", 7),
        (agent_get_defend_action, ":var_3", ":var_0"),
        (eq, ":var_3", 2),
        (agent_get_horse, ":var_4", ":var_0"),
        (eq, ":var_4", -1),
        (agent_set_slot, ":var_0", 249, 5),
        (agent_set_animation, ":var_0", "anim_shield_bash"),
        (agent_get_troop_id, ":var_5", ":var_0"),
        (troop_get_type, ":var_2", ":var_5"),
        (try_begin),
            (eq, ":var_2", 0),
            (agent_play_sound, ":var_0", "snd_man_yell"),
        (else_try),
            (eq, ":var_2", 1),
            (agent_play_sound, ":var_0", "snd_woman_yell"),
        (try_end),
        (agent_get_position, pos1, ":var_0"),
        (assign, ":var_6", -1),
        (assign, ":var_7", 150),
        (try_for_agents, ":var_8"),
            (agent_is_alive, ":var_8"),
            (agent_is_human, ":var_8"),
            (neg|agent_is_ally, ":var_8"),
            (agent_get_position, pos2, ":var_8"),
            (neg|position_is_behind_position, 2, 1),
            (get_distance_between_positions, ":var_9", pos1, pos2),
            (neg|gt, ":var_9", ":var_7"),
            (assign, ":var_7", ":var_9"),
            (assign, ":var_6", ":var_8"),
        (try_end),
        (ge, ":var_6", 0),
        (agent_play_sound, ":var_6", "snd_wooden_hit_low_armor_high_damage"),
        (agent_get_defend_action, ":var_3", ":var_6"),
        (try_begin),
            (eq, ":var_3", 2),
            (neg|position_is_behind_position, 1, 2),
            (agent_get_wielded_item, ":var_1", ":var_6", 1),
            (gt, ":var_1", 0),
            (item_get_type, ":var_2", ":var_1"),
            (eq, ":var_2", 7),
        (else_try),
            (agent_set_animation, ":var_6", "anim_shield_strike"),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (agent_is_active, ":var_0"),
        (agent_is_alive, ":var_0"),
        (agent_get_slot, ":var_1", ":var_0", 249),
        (val_sub, ":var_1", 1),
        (val_max, ":var_1", 0),
        (agent_set_slot, ":var_0", 249, ":var_1"),
    ]),

    (0.250000, 0.000000, 0.000000, 
    [
        (eq, "$g_option_use_shield_bash", 1),
    ],
    [
        (get_player_agent_no, ":var_0"),
        (try_for_agents, ":var_1"),
            (neg|eq, ":var_1", ":var_0"),
            (agent_is_alive, ":var_1"),
            (agent_is_human, ":var_1"),
            (agent_get_troop_id, ":var_2", ":var_1"),
            (store_skill_level, ":var_3", skl_shield, ":var_2"),
            (store_proficiency_level, ":var_4", ":var_2", wpt_one_handed_weapon),
            (ge, ":var_3", 4),
            (ge, ":var_4", 200),
            (store_random_in_range, ":var_4", 1, 11),
            (neg|gt, ":var_4", 2),
            (neg|troop_is_mounted, ":var_2"),
            (try_begin),
                (neg|agent_slot_ge, ":var_1", 249, 1),
                (agent_slot_eq, ":var_1", slot_agent_is_running_away, 0),
                (agent_get_wielded_item, ":var_5", ":var_1", 1),
                (gt, ":var_5", 0),
                (item_get_type, ":var_6", ":var_5"),
                (eq, ":var_6", 7),
                (agent_get_attack_action, ":var_7", ":var_1"),
                (eq, ":var_7", 0),
                (agent_get_horse, ":var_8", ":var_1"),
                (eq, ":var_8", -1),
                (agent_get_team, ":var_9", ":var_1"),
                (agent_get_position, pos1, ":var_1"),
                (assign, ":var_10", -1),
                (assign, ":var_11", 125),
                (try_for_agents, ":var_12"),
                    (agent_is_alive, ":var_12"),
                    (agent_is_human, ":var_12"),
                    (agent_get_position, pos2, ":var_12"),
                    (neg|position_is_behind_position, 2, 1),
                    (agent_get_team, ":var_13", ":var_12"),
                    (teams_are_enemies, ":var_13", ":var_9"),
                    (get_distance_between_positions, ":var_14", pos1, pos2),
                    (neg|gt, ":var_14", ":var_11"),
                    (assign, ":var_11", ":var_14"),
                    (assign, ":var_10", ":var_12"),
                (try_end),
                (ge, ":var_10", 0),
                (agent_get_horse, ":var_8", ":var_10"),
                (eq, ":var_8", -1),
                (store_random_in_range, ":var_15", 0, 1000),
                (store_character_level, ":var_16", ":var_2"),
                (store_div, ":var_17", ":var_16", 2),
                (store_mul, ":var_18", ":var_3", 10),
                (store_div, ":var_19", ":var_4", 10),
                (store_add, ":var_20", ":var_17", ":var_19"),
                (val_add, ":var_20", ":var_18"),
                (val_sub, ":var_20", 15),
                (val_clamp, ":var_20", 40, 150),
                (neg|ge, ":var_15", ":var_20"),
                (store_random_in_range, ":var_15", 15, 26),
                (agent_set_slot, ":var_1", 249, ":var_15"),
                (agent_set_animation, ":var_1", "anim_shield_bash"),
                (agent_get_troop_id, ":var_2", ":var_1"),
                (troop_get_type, ":var_6", ":var_2"),
                (try_begin),
                    (eq, ":var_6", 0),
                    (agent_play_sound, ":var_1", "snd_man_yell"),
                (else_try),
                    (eq, ":var_6", 1),
                    (agent_play_sound, ":var_1", "snd_woman_yell"),
                (try_end),
                (agent_play_sound, ":var_10", "snd_wooden_hit_low_armor_high_damage"),
                (agent_get_defend_action, ":var_7", ":var_10"),
                (try_begin),
                    (eq, ":var_7", 2),
                    (neg|position_is_behind_position, 1, 2),
                    (agent_get_wielded_item, ":var_5", ":var_10", 1),
                    (gt, ":var_5", 0),
                    (item_get_type, ":var_6", ":var_5"),
                    (eq, ":var_6", 7),
                (else_try),
                    (agent_set_animation, ":var_10", "anim_shield_strike"),
                (try_end),
            (try_end),
            (agent_get_slot, ":var_21", ":var_1", 249),
            (val_sub, ":var_21", 1),
            (val_max, ":var_21", 0),
            (agent_set_slot, ":var_1", 249, ":var_21"),
        (try_end),
    ]),


],),

(
"multiplayer_duel", 2, -1, 
"You_lead_your_men_to_battle.",
[(0, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(1, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(2, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(3, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(4, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(5, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(6, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(7, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(8, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(9, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(10, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(11, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(12, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(13, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(14, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(15, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(16, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(17, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(18, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(19, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(20, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(21, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(22, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(23, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(24, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(25, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(26, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(27, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(28, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(29, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(30, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(31, mtef_visitor_source|mtef_team_0, 0, 16, 1, []),
(32, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(33, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(34, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(35, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(36, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(37, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(38, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(39, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(40, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(41, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(42, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(43, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(44, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(45, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(46, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(47, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(48, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(49, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(50, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(51, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(52, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(53, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(54, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(55, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(56, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(57, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(58, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(59, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(60, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(61, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(62, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
(63, mtef_visitor_source|mtef_team_1, 0, 16, 1, []),
],
[
    (1.000000, 5.000000, 0.000000, 
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_poll_running", 1),
        (eq, "$g_multiplayer_poll_ended", 0),
        (store_mission_timer_a, ":var_0"),
        (store_add, ":var_1", "$g_multiplayer_poll_no_count", "$g_multiplayer_poll_yes_count"),
        (this_or_next|eq, ":var_1", "$g_multiplayer_poll_num_sent"),
        (gt, ":var_0", "$g_multiplayer_poll_end_time"),
        (call_script, "script_cf_multiplayer_evaluate_poll"),
    ],
    [
        (assign, "$g_multiplayer_poll_running", 0),
        (try_begin),
            (this_or_next|eq, "$g_multiplayer_poll_to_show", 0),
            (eq, "$g_multiplayer_poll_to_show", 3),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_poll_value_to_show", 1),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_on_agent_spawn, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_on_agent_spawn_common", ":var_0"),
    ]),

    (ti_server_player_joined, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (call_script, "script_multiplayer_server_player_joined_common", ":var_0"),
    ]),

    (ti_before_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (assign, "$g_multiplayer_game_type", 7),
        (call_script, "script_multiplayer_server_before_mission_start_common"),
        (team_set_relation, 0, 0, 1),
        (team_set_relation, 0, 1, 1),
        (team_set_relation, 1, 1, 1),
        (mission_set_duel_mode, 1),
        (call_script, "script_multiplayer_init_mission_variables"),
        (call_script, "script_multiplayer_remove_destroy_mod_targets"),
        (call_script, "script_multiplayer_remove_headquarters_flags"),
    ]),

    (ti_after_mission_start, 0.000000, 0.000000, 
    [
    ],
    [
        (set_spawn_effector_scene_prop_kind, 0, -1),
        (set_spawn_effector_scene_prop_kind, 1, -1),
        (call_script, "script_initialize_all_scene_prop_slots"),
        (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
        (assign, "$g_multiplayer_ready_for_spawning_agent", 1),
    ]),

    (ti_on_multiplayer_mission_end, 0.000000, 0.000000, 
    [
    ],
    [
        (call_script, "script_multiplayer_event_mission_end"),
        (assign, "$g_multiplayer_stats_chart_opened_manually", 0),
        (start_presentation, "prsnt_multiplayer_stats_chart_deathmatch"),
    ]),

    (ti_on_agent_killed_or_wounded, 0.000000, 0.000000, 
    [
    ],
    [
        (store_trigger_param_1, ":var_0"),
        (store_trigger_param_2, ":var_1"),
        (call_script, "script_multiplayer_server_on_agent_killed_or_wounded_common", ":var_0", ":var_1"),
        (try_begin),
            (get_player_agent_no, ":var_2"),
            (agent_is_active, ":var_2"),
            (agent_slot_ge, ":var_2", slot_agent_in_duel_with, 0),
            (try_begin),
                (eq, ":var_0", ":var_2"),
                (display_message, "str_you_have_lost_a_duel"),
            (else_try),
                (agent_slot_eq, ":var_2", slot_agent_in_duel_with, ":var_0"),
                (display_message, "str_you_have_won_a_duel"),
            (try_end),
        (try_end),
        (try_begin),
            (agent_slot_ge, ":var_0", slot_agent_in_duel_with, 0),
            (agent_get_slot, ":var_3", ":var_0", slot_agent_in_duel_with),
            (agent_set_slot, ":var_0", slot_agent_in_duel_with, -1),
            (try_begin),
                (agent_is_active, ":var_3"),
                (agent_set_slot, ":var_3", slot_agent_in_duel_with, -1),
                (agent_clear_relations_with_agents, ":var_3"),
                (try_begin),
                    (agent_get_player_id, ":var_4", ":var_3"),
                    (neg|player_is_active, ":var_4"),
                    (agent_force_rethink, ":var_3"),
                (try_end),
            (try_end),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (get_max_players, ":var_0"),
        (try_for_range, ":var_1", 0, ":var_0"),
            (player_is_active, ":var_1"),
            (neg|player_is_busy_with_menus, ":var_1"),
            (player_get_team_no, ":var_2", ":var_1"),
            (neg|ge, ":var_2", 2),
            (player_get_troop_id, ":var_3", ":var_1"),
            (ge, ":var_3", 0),
            (player_get_agent_id, ":var_4", ":var_1"),
            (assign, ":var_5", 0),
            (try_begin),
                (player_get_slot, ":var_6", ":var_1", 24),
                (eq, ":var_6", 1),
                (assign, ":var_5", 1),
                (player_set_slot, ":var_1", 24, 0),
            (else_try),
                (try_begin),
                    (neg|ge, ":var_4", 0),
                    (assign, ":var_5", 1),
                (else_try),
                    (neg|agent_is_alive, ":var_4"),
                    (agent_get_time_elapsed_since_removed, ":var_7", ":var_4"),
                    (gt, ":var_7", "$g_multiplayer_respawn_period"),
                    (assign, ":var_5", 1),
                (try_end),
            (try_end),
            (eq, ":var_5", 1),
            (call_script, "script_multiplayer_buy_agent_equipment", ":var_1"),
            (troop_get_inventory_slot, ":var_8", ":var_3", 8),
            (try_begin),
                (ge, ":var_8", 0),
                (assign, ":var_9", 1),
            (else_try),
                (assign, ":var_9", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_9"),
            (player_spawn_new_agent, ":var_1", reg0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (store_mission_timer_a, ":var_0"),
        (ge, ":var_0", 2),
        (assign, ":var_1", 0),
        (assign, ":var_2", 0),
        (try_for_agents, ":var_3"),
            (agent_is_non_player, ":var_3"),
            (agent_is_human, ":var_3"),
            (assign, ":var_4", 0),
            (try_begin),
                (agent_is_alive, ":var_3"),
                (assign, ":var_4", 1),
            (else_try),
                (agent_get_time_elapsed_since_removed, ":var_5", ":var_3"),
                (neg|gt, ":var_5", "$g_multiplayer_respawn_period"),
                (assign, ":var_4", 1),
            (try_end),
            (eq, ":var_4", 1),
            (agent_get_team, ":var_6", ":var_3"),
            (try_begin),
                (eq, ":var_6", 0),
                (val_add, ":var_1", 1),
            (else_try),
                (eq, ":var_6", 1),
                (val_add, ":var_2", 1),
            (try_end),
        (try_end),
        (store_sub, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1", ":var_1"),
        (store_sub, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2", ":var_2"),
        (val_max, "$g_multiplayer_num_bots_required_team_1", 0),
        (val_max, "$g_multiplayer_num_bots_required_team_2", 0),
    ]),

    (0.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (eq, "$g_multiplayer_ready_for_spawning_agent", 1),
        (store_add, ":var_0", "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_required_team_2"),
        (try_begin),
            (gt, ":var_0", 0),
            (store_random_in_range, ":var_1", 0, ":var_0"),
            (val_sub, ":var_1", "$g_multiplayer_num_bots_required_team_1"),
            (try_begin),
                (neg|ge, ":var_1", 0),
                (assign, ":var_2", 0),
                (val_sub, "$g_multiplayer_num_bots_required_team_1", 1),
            (else_try),
                (assign, ":var_2", 1),
                (val_sub, "$g_multiplayer_num_bots_required_team_2", 1),
            (try_end),
            (team_get_faction, ":var_3", ":var_2"),
            (assign, ":var_4", 0),
            (try_for_range, ":var_5", "trp_sarleon_longbowman_multiplayer_ai", "trp_sarleon_longbowman_multiplayer"),
                (store_troop_faction, ":var_6", ":var_5"),
                (eq, ":var_6", ":var_3"),
                (val_add, ":var_4", 1),
            (try_end),
            (store_random_in_range, ":var_7", 0, ":var_4"),
            (assign, ":var_8", "trp_sarleon_longbowman_multiplayer"),
            (try_for_range, ":var_5", "trp_sarleon_longbowman_multiplayer_ai", ":var_8"),
                (store_troop_faction, ":var_6", ":var_5"),
                (eq, ":var_6", ":var_3"),
                (val_sub, ":var_7", 1),
                (neg|ge, ":var_7", 0),
                (assign, ":var_8", 0),
                (assign, ":var_9", ":var_5"),
            (try_end),
            (troop_get_inventory_slot, ":var_10", ":var_9", 8),
            (try_begin),
                (ge, ":var_10", 0),
                (assign, ":var_11", 1),
            (else_try),
                (assign, ":var_11", 0),
            (try_end),
            (call_script, "script_multiplayer_find_spawn_point", ":var_2", 0, ":var_11"),
            (store_current_scene, ":var_12"),
            (modify_visitors_at_site, ":var_12"),
            (add_visitors_to_current_scene, reg0, ":var_9", 1, ":var_2", -1),
            (assign, "$g_multiplayer_ready_for_spawning_agent", 0),
        (try_end),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (multiplayer_is_server),
        (assign, ":var_0", 0),
        (try_begin),
            (store_mission_timer_a, ":var_1"),
            (store_mul, ":var_2", "$g_multiplayer_game_max_minutes", 60),
            (gt, ":var_1", ":var_2"),
            (assign, ":var_0", 1),
        (try_end),
        (try_begin),
            (eq, ":var_0", 1),
            (call_script, "script_game_multiplayer_get_game_type_mission_template", "$g_multiplayer_game_type"),
            (start_multiplayer_mission, reg0, "$g_multiplayer_selected_map", 0),
            (call_script, "script_game_set_multiplayer_mission_end"),
        (try_end),
    ]),

    (ti_tab_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (try_begin),
            (eq, "$g_multiplayer_mission_end_screen", 0),
            (assign, "$g_multiplayer_stats_chart_opened_manually", 1),
            (start_presentation, "prsnt_multiplayer_stats_chart_deathmatch"),
        (try_end),
    ]),

    (0.000000, 0.000000, ti_once, 
    [
    ],
    [
        (start_presentation, "prsnt_multiplayer_welcome_message"),
    ]),

    (ti_escape_pressed, 0.000000, 0.000000, 
    [
    ],
    [
        (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
        (neg|is_presentation_active, "prsnt_multiplayer_stats_chart_deathmatch"),
        (eq, "$g_waiting_for_confirmation_to_terminate", 0),
        (start_presentation, "prsnt_multiplayer_escape_menu"),
    ]),

    (1.000000, 0.000000, 0.000000, 
    [
    ],
    [
        (store_mission_timer_a, ":var_0"),
        (store_sub, ":var_1", ":var_0", 3),
        (try_for_agents, ":var_2"),
            (agent_slot_ge, ":var_2", slot_agent_in_duel_with, 0),
            (agent_get_slot, ":var_3", ":var_2", slot_agent_duel_start_time),
            (ge, ":var_3", 0),
            (neg|gt, ":var_3", ":var_1"),
            (agent_set_slot, ":var_2", slot_agent_duel_start_time, -1),
            (agent_get_slot, ":var_4", ":var_2", slot_agent_in_duel_with),
            (agent_is_active, ":var_4"),
            (agent_add_relation_with_agent, ":var_2", ":var_4", -1),
            (agent_force_rethink, ":var_2"),
        (try_end),
    ]),


],),


]